File tree Expand file tree Collapse file tree 3 files changed +18
-31
lines changed
Expand file tree Collapse file tree 3 files changed +18
-31
lines changed Original file line number Diff line number Diff line change 11"""When called as a script, print a comma-separated list of the open
2- file descriptors on stdout."""
2+ file descriptors on stdout.
3+
4+ Usage:
5+ fd_stats.py: check all file descriptors
6+ fd_status.py fd1 fd2 ...: check only specified file descriptors
7+ """
38
49import errno
510import os
611import stat
7-
8- try :
9- _MAXFD = os .sysconf ("SC_OPEN_MAX" )
10- except :
11- _MAXFD = 256
12+ import sys
1213
1314if __name__ == "__main__" :
1415 fds = []
15- for fd in range (0 , _MAXFD ):
16+ if len (sys .argv ) == 1 :
17+ try :
18+ _MAXFD = os .sysconf ("SC_OPEN_MAX" )
19+ except :
20+ _MAXFD = 256
21+ test_fds = range (0 , _MAXFD )
22+ else :
23+ test_fds = map (int , sys .argv [1 :])
24+ for fd in test_fds :
1625 try :
1726 st = os .fstat (fd )
1827 except OSError as e :
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -1926,7 +1926,7 @@ def test_pass_fds(self):
19261926 self .assertIn ('overriding close_fds' , str (context .warning ))
19271927
19281928 def test_pass_fds_inheritable (self ):
1929- script = support .findfile ("inherited .py" , subdir = "subprocessdata" )
1929+ script = support .findfile ("fd_status .py" , subdir = "subprocessdata" )
19301930
19311931 inheritable , non_inheritable = os .pipe ()
19321932 self .addCleanup (os .close , inheritable )
@@ -1945,7 +1945,7 @@ def test_pass_fds_inheritable(self):
19451945
19461946 # the inheritable file descriptor must be inherited, so its inheritable
19471947 # flag must be set in the child process after fork() and before exec()
1948- self .assertEqual (fds , set (pass_fds ))
1948+ self .assertEqual (fds , set (pass_fds ), "output=%a" % output )
19491949
19501950 # inheritable flag must not be changed in the parent process
19511951 self .assertEqual (os .get_inheritable (inheritable ), True )
You can’t perform that action at this time.
0 commit comments