Skip to content

Commit

Permalink
compat/ssubprocess.py: some python versions don't have os.closerange().
Browse files Browse the repository at this point in the history
Like python2.5 on Debian.  It might be a MacOS extension or something.  So
much for the comment in subprocess.py that said "keep this compatible with
python 2.2."
  • Loading branch information
apenwarr committed Oct 2, 2010
1 parent 76d576a commit 52fbb2e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions compat/ssubprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,17 @@ def list2cmdline(seq):
return ''.join(result)


def _closerange(start, max):
try:
os.closerange(start, max)
except AttributeError:
for i in xrange(start, max):
try:
os.close(i)
except:
pass


class Popen(object):
def __init__(self, args, bufsize=0, executable=None,
stdin=None, stdout=None, stderr=None,
Expand Down Expand Up @@ -989,8 +1000,8 @@ def _set_cloexec_flag(self, fd):


def _close_fds(self, but):
os.closerange(3, but)
os.closerange(but + 1, MAXFD)
_closerange(3, but)
_closerange(but + 1, MAXFD)


def _execute_child(self, args, executable, preexec_fn, close_fds,
Expand Down

0 comments on commit 52fbb2e

Please sign in to comment.