diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-01-03 23:42:01 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-01-03 23:42:01 (GMT) |
commit | 47f14bade8f1d9517fca4bcddb1162f4e9845e12 (patch) | |
tree | f5ce1d3855ed5067841683c171a94f3ab7256069 /Lib/subprocess.py | |
parent | dcdc3b4c5d2fa0522564032359f0f92146670d5e (diff) | |
download | cpython-47f14bade8f1d9517fca4bcddb1162f4e9845e12.zip cpython-47f14bade8f1d9517fca4bcddb1162f4e9845e12.tar.gz cpython-47f14bade8f1d9517fca4bcddb1162f4e9845e12.tar.bz2 |
Un-complicate some code
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r-- | Lib/subprocess.py | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 7d3f77f..5c5e9f2 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -1092,15 +1092,9 @@ class Popen(object): errread, errwrite) - def _close_fds(self, but): - os.closerange(3, but) - os.closerange(but + 1, MAXFD) - - - def _close_all_but_a_sorted_few_fds(self, fds_to_keep): - # precondition: fds_to_keep must be sorted and unique + def _close_fds(self, fds_to_keep): start_fd = 3 - for fd in fds_to_keep: + for fd in sorted(fds_to_keep): if fd >= start_fd: os.closerange(start_fd, fd) start_fd = fd + 1 @@ -1216,13 +1210,9 @@ class Popen(object): # Close all other fds, if asked for if close_fds: - if pass_fds: - fds_to_keep = set(pass_fds) - fds_to_keep.add(errpipe_write) - self._close_all_but_a_sorted_few_fds( - sorted(fds_to_keep)) - else: - self._close_fds(but=errpipe_write) + fds_to_keep = set(pass_fds) + fds_to_keep.add(errpipe_write) + self._close_fds(fds_to_keep) if cwd is not None: |