diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-09-19 19:58:29 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-09-19 19:58:29 -0700 |
commit | 146dea1276fcecb641ee57f080a4d8f2ccce1396 (patch) | |
tree | ee1eef6a2ab73d48cfd34488fe438ee0c94c685b | |
parent | dfc634ab5f36b6b098bd48651f9a338b473f01e8 (diff) | |
download | portage-146dea1276fcecb641ee57f080a4d8f2ccce1396.tar.gz portage-146dea1276fcecb641ee57f080a4d8f2ccce1396.tar.bz2 portage-146dea1276fcecb641ee57f080a4d8f2ccce1396.zip |
With waitpid and WNOHANG, only check the first element of the tuplev2.2_rc85
since the second element may vary (bug #337465, comment #12).
-rw-r--r-- | pym/_emerge/SubProcess.py | 10 | ||||
-rw-r--r-- | pym/_emerge/actions.py | 5 | ||||
-rw-r--r-- | pym/portage/process.py | 10 |
3 files changed, 20 insertions, 5 deletions
diff --git a/pym/_emerge/SubProcess.py b/pym/_emerge/SubProcess.py index 0013d7391..b2b19d54d 100644 --- a/pym/_emerge/SubProcess.py +++ b/pym/_emerge/SubProcess.py @@ -25,6 +25,9 @@ class SubProcess(AbstractPollTask): return self.returncode try: + # With waitpid and WNOHANG, only check the + # first element of the tuple since the second + # element may vary (bug #337465). retval = os.waitpid(self.pid, os.WNOHANG) except OSError as e: if e.errno != errno.ECHILD: @@ -32,7 +35,7 @@ class SubProcess(AbstractPollTask): del e retval = (self.pid, 1) - if retval == (0, 0): + if retval[0] == 0: return None self._set_returncode(retval) return self.returncode @@ -81,6 +84,9 @@ class SubProcess(AbstractPollTask): return self.returncode try: + # With waitpid and WNOHANG, only check the + # first element of the tuple since the second + # element may vary (bug #337465). wait_retval = os.waitpid(self.pid, os.WNOHANG) except OSError as e: if e.errno != errno.ECHILD: @@ -88,7 +94,7 @@ class SubProcess(AbstractPollTask): del e self._set_returncode((self.pid, 1)) else: - if wait_retval != (0, 0): + if wait_retval[0] != 0: self._set_returncode(wait_retval) else: try: diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index eb02a0304..92eb18b74 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -2177,7 +2177,10 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): except portage.exception.AlarmSignal: # timed out print('timed out') - if mypids and os.waitpid(mypids[0], os.WNOHANG) == (0,0): + # With waitpid and WNOHANG, only check the + # first element of the tuple since the second + # element may vary (bug #337465). + if mypids and os.waitpid(mypids[0], os.WNOHANG)[0] == 0: os.kill(mypids[0], signal.SIGTERM) os.waitpid(mypids[0], 0) # This is the same code rsync uses for timeout. diff --git a/pym/portage/process.py b/pym/portage/process.py index 2787e0884..37b482a0e 100644 --- a/pym/portage/process.py +++ b/pym/portage/process.py @@ -135,7 +135,10 @@ def cleanup(): while spawned_pids: pid = spawned_pids.pop() try: - if os.waitpid(pid, os.WNOHANG) == (0, 0): + # With waitpid and WNOHANG, only check the + # first element of the tuple since the second + # element may vary (bug #337465). + if os.waitpid(pid, os.WNOHANG)[0] == 0: os.kill(pid, signal.SIGTERM) os.waitpid(pid, 0) except OSError: @@ -289,7 +292,10 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False, # If it failed, kill off anything else that # isn't dead yet. for pid in mypids: - if os.waitpid(pid, os.WNOHANG) == (0,0): + # With waitpid and WNOHANG, only check the + # first element of the tuple since the second + # element may vary (bug #337465). + if os.waitpid(pid, os.WNOHANG)[0] == 0: os.kill(pid, signal.SIGTERM) os.waitpid(pid, 0) spawned_pids.remove(pid) |