File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44import errno
55import os
6- import fcntl
76
87try :
98 _MAXFD = os .sysconf ("SC_OPEN_MAX" )
109except :
1110 _MAXFD = 256
1211
13- def isopen (fd ):
14- """Return True if the fd is open, and False otherwise"""
15- try :
16- fcntl .fcntl (fd , fcntl .F_GETFD , 0 )
17- except IOError as e :
18- if e .errno == errno .EBADF :
19- return False
20- raise
21- return True
22-
2312if __name__ == "__main__" :
24- print (',' .join (str (fd ) for fd in range (0 , _MAXFD ) if isopen (fd )))
13+ fds = []
14+ for fd in range (0 , _MAXFD ):
15+ try :
16+ st = os .fstat (fd )
17+ except OSError as e :
18+ if e .errno == errno .EBADF :
19+ continue
20+ raise
21+ # Ignore Solaris door files
22+ if st .st_mode & 0xF000 != 0xd000 :
23+ fds .append (fd )
24+ print (',' .join (map (str , fds )))
Original file line number Diff line number Diff line change @@ -1156,9 +1156,6 @@ def test_pass_fds(self):
11561156
11571157 open_fds = set ()
11581158
1159- if support .verbose :
1160- print (" -- maxfd =" , subprocess .MAXFD )
1161-
11621159 for x in range (5 ):
11631160 fds = os .pipe ()
11641161 self .addCleanup (os .close , fds [0 ])
@@ -1173,10 +1170,6 @@ def test_pass_fds(self):
11731170
11741171 remaining_fds = set (map (int , output .split (b',' )))
11751172 to_be_closed = open_fds - {fd }
1176- # Temporary debug output for intermittent failures
1177- if support .verbose :
1178- print (" -- fds that should have been closed:" , to_be_closed )
1179- print (" -- fds that remained open:" , remaining_fds )
11801173
11811174 self .assertIn (fd , remaining_fds , "fd to be passed not passed" )
11821175 self .assertFalse (remaining_fds & to_be_closed ,
Original file line number Diff line number Diff line change 2727- Issue #11268: Prevent Mac OS X Installer failure if Documentation
2828 package had previously been installed.
2929
30+ Tests
31+ -----
32+
33+ - Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
34+ to open door files.
35+
3036
3137What's New in Python 3.2?
3238=========================
You can’t perform that action at this time.
0 commit comments