gh-134954: Hard-cap max file descriptors in subprocess test fd_status (#134955)
* Hard-cap max file descriptors in subprocess test fd_status On some systems, `SC_OPEN_MAX` may return a very large value (i.e. 10**30), leading to the subprocess test timing out (or run forever). Prevent this situation by applying a hard cap on how many file descriptors are checked. * Fix typo in usage docstring s/fd_stats/fd_status/
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
file descriptors on stdout.
|
file descriptors on stdout.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
fd_stats.py: check all file descriptors
|
fd_status.py: check all file descriptors (up to 255)
|
||||||
fd_status.py fd1 fd2 ...: check only specified file descriptors
|
fd_status.py fd1 fd2 ...: check only specified file descriptors
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ if __name__ == "__main__":
|
|||||||
_MAXFD = os.sysconf("SC_OPEN_MAX")
|
_MAXFD = os.sysconf("SC_OPEN_MAX")
|
||||||
except:
|
except:
|
||||||
_MAXFD = 256
|
_MAXFD = 256
|
||||||
test_fds = range(0, _MAXFD)
|
test_fds = range(0, min(_MAXFD, 256))
|
||||||
else:
|
else:
|
||||||
test_fds = map(int, sys.argv[1:])
|
test_fds = map(int, sys.argv[1:])
|
||||||
for fd in test_fds:
|
for fd in test_fds:
|
||||||
|
|||||||
Reference in New Issue
Block a user