Mercurial > cpython-lru_cache-weakref
annotate Lib/test/subprocessdata/fd_status.py @ 78069:a8aa77458e12 3.2
Add c_size_t and c_ssize_t to the ctypes summary table.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Thu, 12 Jul 2012 20:31:50 +0200 |
| parents | f5e9c17b85ad |
| children | fed15a462aa5 |
| rev | line source |
|---|---|
|
66868
de05d846795e
issue7213: Open the pipes used by subprocesses with the FD_CLOEXEC flag from
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
1 """When called as a script, print a comma-separated list of the open |
|
de05d846795e
issue7213: Open the pipes used by subprocesses with the FD_CLOEXEC flag from
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
2 file descriptors on stdout.""" |
|
de05d846795e
issue7213: Open the pipes used by subprocesses with the FD_CLOEXEC flag from
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
3 |
|
de05d846795e
issue7213: Open the pipes used by subprocesses with the FD_CLOEXEC flag from
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
4 import errno |
|
de05d846795e
issue7213: Open the pipes used by subprocesses with the FD_CLOEXEC flag from
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
5 import os |
|
de05d846795e
issue7213: Open the pipes used by subprocesses with the FD_CLOEXEC flag from
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
6 |
|
de05d846795e
issue7213: Open the pipes used by subprocesses with the FD_CLOEXEC flag from
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
7 try: |
|
de05d846795e
issue7213: Open the pipes used by subprocesses with the FD_CLOEXEC flag from
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
8 _MAXFD = os.sysconf("SC_OPEN_MAX") |
|
de05d846795e
issue7213: Open the pipes used by subprocesses with the FD_CLOEXEC flag from
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
9 except: |
|
de05d846795e
issue7213: Open the pipes used by subprocesses with the FD_CLOEXEC flag from
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
10 _MAXFD = 256 |
|
de05d846795e
issue7213: Open the pipes used by subprocesses with the FD_CLOEXEC flag from
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
11 |
|
de05d846795e
issue7213: Open the pipes used by subprocesses with the FD_CLOEXEC flag from
Gregory P. Smith <greg@mad-scientist.com>
parents:
diff
changeset
|
12 if __name__ == "__main__": |
|
68088
f5e9c17b85ad
Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
Antoine Pitrou <solipsis@pitrou.net>
parents:
66868
diff
changeset
|
13 fds = [] |
|
f5e9c17b85ad
Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
Antoine Pitrou <solipsis@pitrou.net>
parents:
66868
diff
changeset
|
14 for fd in range(0, _MAXFD): |
|
f5e9c17b85ad
Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
Antoine Pitrou <solipsis@pitrou.net>
parents:
66868
diff
changeset
|
15 try: |
|
f5e9c17b85ad
Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
Antoine Pitrou <solipsis@pitrou.net>
parents:
66868
diff
changeset
|
16 st = os.fstat(fd) |
|
f5e9c17b85ad
Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
Antoine Pitrou <solipsis@pitrou.net>
parents:
66868
diff
changeset
|
17 except OSError as e: |
|
f5e9c17b85ad
Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
Antoine Pitrou <solipsis@pitrou.net>
parents:
66868
diff
changeset
|
18 if e.errno == errno.EBADF: |
|
f5e9c17b85ad
Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
Antoine Pitrou <solipsis@pitrou.net>
parents:
66868
diff
changeset
|
19 continue |
|
f5e9c17b85ad
Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
Antoine Pitrou <solipsis@pitrou.net>
parents:
66868
diff
changeset
|
20 raise |
|
f5e9c17b85ad
Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
Antoine Pitrou <solipsis@pitrou.net>
parents:
66868
diff
changeset
|
21 # Ignore Solaris door files |
|
f5e9c17b85ad
Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
Antoine Pitrou <solipsis@pitrou.net>
parents:
66868
diff
changeset
|
22 if st.st_mode & 0xF000 != 0xd000: |
|
f5e9c17b85ad
Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
Antoine Pitrou <solipsis@pitrou.net>
parents:
66868
diff
changeset
|
23 fds.append(fd) |
|
f5e9c17b85ad
Issue #10826: Prevent sporadic failure in test_subprocess on Solaris due
Antoine Pitrou <solipsis@pitrou.net>
parents:
66868
diff
changeset
|
24 print(','.join(map(str, fds))) |
