pexpect / ptyprocess

Run a subprocess in a pseudo terminal
https://ptyprocess.readthedocs.io/en/latest/
Other
217 stars 71 forks source link

Fix AIX bug for users with unlimited nofiles #41

Closed shmaix closed 7 years ago

shmaix commented 7 years ago

When using pexpect on AIX, I encountered a bug where os.close() in openpty would hang when running under particular user accounts which had nofiles ulimit set to unlimited. After tracing, it appears that resource.RLIMIT_NOFILE for these users is 2^63-1, and os.closerange() was attempting to close a huge number of fds. Putting an arbitrary ceiling on max_fds resolves the issue. Feel free to increase/lower ceiling as desired, or put under an AIX OS check to further isolate.

takluyver commented 7 years ago

I thought the idea of closerange() was that the OS could handle it efficiently even if the range was huge, because it doesn't need to try every possible number as an fd. I think this is reasonable, though.

shmaix commented 7 years ago

Agree, that was my understanding of closerange() as well. I think this is most likely a Python-AIX implementation issue, it wouldn't be the first I've come across, I'll be raising a support call to IBM to take a look as well. Thanks! :)