diff options
author | Zac Medico <zmedico@gentoo.org> | 2013-01-15 06:12:27 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2013-01-15 06:12:27 -0800 |
commit | 04f8dfb158bcadc1017a64e9fad5e744d4f91f9c (patch) | |
tree | 730fef73bb94c596b982c22c88b4e34538aec211 /pym | |
parent | a8d775aeb0256e8fbde687ea44749b81bfd2b509 (diff) | |
download | portage-04f8dfb158bcadc1017a64e9fad5e744d4f91f9c.tar.gz portage-04f8dfb158bcadc1017a64e9fad5e744d4f91f9c.tar.bz2 portage-04f8dfb158bcadc1017a64e9fad5e744d4f91f9c.zip |
SpawnProcess: avoid fd_pipes interference
This fixes a random collision that can occur with FileDigester,
triggering malfunction and a KeyError.
Diffstat (limited to 'pym')
-rw-r--r-- | pym/_emerge/SpawnProcess.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py index 5d0fcf6dd..9c754add5 100644 --- a/pym/_emerge/SpawnProcess.py +++ b/pym/_emerge/SpawnProcess.py @@ -76,8 +76,14 @@ class SpawnProcess(SubProcess): else: # Create a dummy pipe so the scheduler can monitor - # the process from inside a poll() loop. - fd_pipes[self._dummy_pipe_fd] = slave_fd + # the process from inside a poll() loop. Ensure that + # it doesn't interfere with a random fd that's already + # in fd_pipes though (as least FileDigester can pass + # in a random fd returned from os.pipe()). + unique_dummy_fd = self._dummy_pipe_fd + while unique_dummy_fd in fd_pipes: + unique_dummy_fd += 1 + fd_pipes[unique_dummy_fd] = slave_fd if self.background: fd_pipes[1] = slave_fd fd_pipes[2] = slave_fd |