parent: have close_nonstandard_fds() ask OS for FD_MAX

pull/167/head
David Wilson 7 years ago
parent 721caafb33
commit 972f77c6b5

@ -50,6 +50,11 @@ from mitogen.core import IOLOG
DOCSTRING_RE = re.compile(r'""".+?"""', re.M | re.S) DOCSTRING_RE = re.compile(r'""".+?"""', re.M | re.S)
COMMENT_RE = re.compile(r'^[ ]*#[^\n]*$', re.M) COMMENT_RE = re.compile(r'^[ ]*#[^\n]*$', re.M)
try:
SC_OPEN_MAX = os.sysconf('SC_OPEN_MAX')
except:
SC_OPEN_MAX = 1024
class Argv(object): class Argv(object):
def __init__(self, argv): def __init__(self, argv):
@ -116,7 +121,7 @@ def disable_echo(fd):
def close_nonstandard_fds(): def close_nonstandard_fds():
for fd in xrange(3, 1024): for fd in xrange(3, SC_OPEN_MAX):
try: try:
os.close(fd) os.close(fd)
except OSError: except OSError:

Loading…
Cancel
Save