diff --git a/recipes/msys2/all/conanfile.py b/recipes/msys2/all/conanfile.py index 7e964badd302a..d667e14b94f0c 100644 --- a/recipes/msys2/all/conanfile.py +++ b/recipes/msys2/all/conanfile.py @@ -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()