mirror of
https://github.com/sshuttle/sshuttle.git
synced 2024-11-25 01:13:37 +01:00
compat/ssubprocess.py: some python versions don't have os.closerange().
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."
This commit is contained in:
parent
76d576a375
commit
52fbb2ebbe
@ -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,
|
||||
@ -989,8 +1000,8 @@ class Popen(object):
|
||||
|
||||
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user