summaryrefslogtreecommitdiffstats
path: root/Lib/test/subprocessdata
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-02-21 21:55:48 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-02-21 21:55:48 (GMT)
commitce58dc7b166a4859f7e6e3483ac59fa679d78be9 (patch)
tree1d64ce745bfba451255ca99da741cb8acfd6be23 /Lib/test/subprocessdata
parent5ed8b2c737a71d6fd56757bd9fe108f2cf886664 (diff)
downloadcpython-ce58dc7b166a4859f7e6e3483ac59fa679d78be9.zip
cpython-ce58dc7b166a4859f7e6e3483ac59fa679d78be9.tar.gz
cpython-ce58dc7b166a4859f7e6e3483ac59fa679d78be9.tar.bz2
Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
to open door files.
Diffstat (limited to 'Lib/test/subprocessdata')
-rw-r--r--Lib/test/subprocessdata/fd_status.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/Lib/test/subprocessdata/fd_status.py b/Lib/test/subprocessdata/fd_status.py
index 083b2f9..1f61e13 100644
--- a/Lib/test/subprocessdata/fd_status.py
+++ b/Lib/test/subprocessdata/fd_status.py
@@ -3,22 +3,22 @@ file descriptors on stdout."""
import errno
import os
-import fcntl
try:
_MAXFD = os.sysconf("SC_OPEN_MAX")
except:
_MAXFD = 256
-def isopen(fd):
- """Return True if the fd is open, and False otherwise"""
- try:
- fcntl.fcntl(fd, fcntl.F_GETFD, 0)
- except IOError as e:
- if e.errno == errno.EBADF:
- return False
- raise
- return True
-
if __name__ == "__main__":
- print(','.join(str(fd) for fd in range(0, _MAXFD) if isopen(fd)))
+ fds = []
+ for fd in range(0, _MAXFD):
+ try:
+ st = os.fstat(fd)
+ except OSError as e:
+ if e.errno == errno.EBADF:
+ continue
+ raise
+ # Ignore Solaris door files
+ if st.st_mode & 0xF000 != 0xd000:
+ fds.append(fd)
+ print(','.join(map(str, fds)))