mirror of
https://github.com/python/cpython.git
synced 2025-07-19 17:25:54 +00:00
Issue #18571: Merge duplicate test code
Merge test/subprocessdata/inherited.py into test/subprocessdata/fd_status.py
This commit is contained in:
parent
8913a6c83d
commit
f6fa22efe0
3 changed files with 18 additions and 31 deletions
|
@ -1,18 +1,27 @@
|
|||
"""When called as a script, print a comma-separated list of the open
|
||||
file descriptors on stdout."""
|
||||
file descriptors on stdout.
|
||||
|
||||
Usage:
|
||||
fd_stats.py: check all file descriptors
|
||||
fd_status.py fd1 fd2 ...: check only specified file descriptors
|
||||
"""
|
||||
|
||||
import errno
|
||||
import os
|
||||
import stat
|
||||
|
||||
try:
|
||||
_MAXFD = os.sysconf("SC_OPEN_MAX")
|
||||
except:
|
||||
_MAXFD = 256
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
fds = []
|
||||
for fd in range(0, _MAXFD):
|
||||
if len(sys.argv) == 1:
|
||||
try:
|
||||
_MAXFD = os.sysconf("SC_OPEN_MAX")
|
||||
except:
|
||||
_MAXFD = 256
|
||||
test_fds = range(0, _MAXFD)
|
||||
else:
|
||||
test_fds = map(int, sys.argv[1:])
|
||||
for fd in test_fds:
|
||||
try:
|
||||
st = os.fstat(fd)
|
||||
except OSError as e:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue