summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDean Perkins <dean.perkins@iag.com.au>2017-06-28 14:50:10 +1000
committerDean Perkins <dean.perkins@iag.com.au>2017-06-28 14:50:10 +1000
commit9388ef361eb754ae3ff6b765f2086205cd070401 (patch)
treeaf41e424579cf3c048acd559bc632f624e000145
parentf80d9775f0c64933019f9bb2f7621455ed5b5a54 (diff)
downloadptyprocess-9388ef361eb754ae3ff6b765f2086205cd070401.tar.gz
Fix AIX bug for users with unlimited nofiles
-rw-r--r--ptyprocess/ptyprocess.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/ptyprocess/ptyprocess.py b/ptyprocess/ptyprocess.py
index cb3efae..fb8e351 100644
--- a/ptyprocess/ptyprocess.py
+++ b/ptyprocess/ptyprocess.py
@@ -251,7 +251,10 @@ class PtyProcess(object):
# Do not allow child to inherit open file descriptors from parent,
# with the exception of the exec_err_pipe_write of the pipe
- max_fd = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
+ # Impose ceiling on max_fd: AIX bugfix for users with unlimited
+ # nofiles where resource.RLIMIT_NOFILE is 2^63-1 and os.closerange()
+ # occasionally raises out of range error
+ max_fd = min(1048576, resource.getrlimit(resource.RLIMIT_NOFILE)[0])
os.closerange(3, exec_err_pipe_write)
os.closerange(exec_err_pipe_write+1, max_fd)