Skip to content

Commit

Permalink
PR 4286: try to kill pacman first on windows only
Browse files Browse the repository at this point in the history
  • Loading branch information
dmn-star committed Jan 25, 2021
1 parent 0048efa commit e774845
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions recipes/msys2/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,24 @@ def _update_pacman(self):
self.run('bash -l -c "pacman -Syu --noconfirm"')

def _kill_pacman(self):
taskkill_exe = os.path.join(os.environ['WINDIR'], 'system32', 'taskkill.exe')

log_out = True
if log_out:
out = subprocess.PIPE
err = subprocess.STDOUT
else:
out = file(os.devnull, 'w')
err = subprocess.PIPE

if os.path.exists(taskkill_exe):
taskkill_cmd = taskkill_exe + ' /f /fi "MODULES eq msys-2.0.dll"'
try:
proc = subprocess.Popen(taskkill_cmd, stdout=out, stderr=err, bufsize=1)
except OSError as e:
if e.errno == errno.ENOENT:
raise ConanException("Cannot kill pacman")
if self.settings.os == "Windows":
taskkill_exe = os.path.join(os.environ['WINDIR'], 'system32', 'taskkill.exe')

log_out = True
if log_out:
out = subprocess.PIPE
err = subprocess.STDOUT
else:
out = file(os.devnull, 'w')
err = subprocess.PIPE

if os.path.exists(taskkill_exe):
taskkill_cmd = taskkill_exe + ' /f /fi "MODULES eq msys-2.0.dll"'
try:
proc = subprocess.Popen(taskkill_cmd, stdout=out, stderr=err, bufsize=1)
except OSError as e:
if e.errno == errno.ENOENT:
raise ConanException("Cannot kill pacman")

def configure(self):
self._kill_pacman()
Expand Down

0 comments on commit e774845

Please sign in to comment.