diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-08-28 00:53:59 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-08-28 00:53:59 +0200 |
commit | daf455554bc21b6b5df0a016ab5fa639d36cc595 (patch) | |
tree | 216f52f9f6d9aed0406b2ce2574e5a02aa93e327 /Lib/test/subprocessdata/inherited.py | |
parent | 46e1ce214b5711e8dae63a1b5a0a7aafb371baf0 (diff) | |
download | cpython-git-daf455554bc21b6b5df0a016ab5fa639d36cc595.tar.gz |
Issue #18571: Implementation of the PEP 446: file descriptors and file handles
are now created non-inheritable; add functions os.get/set_inheritable(),
os.get/set_handle_inheritable() and socket.socket.get/set_inheritable().
Diffstat (limited to 'Lib/test/subprocessdata/inherited.py')
-rw-r--r-- | Lib/test/subprocessdata/inherited.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/subprocessdata/inherited.py b/Lib/test/subprocessdata/inherited.py new file mode 100644 index 0000000000..1aac041b34 --- /dev/null +++ b/Lib/test/subprocessdata/inherited.py @@ -0,0 +1,22 @@ +"""Similar to fd_status.py, but only checks file descriptors passed on the +command line.""" + +import errno +import os +import sys +import stat + +if __name__ == "__main__": + fds = map(int, sys.argv[1:]) + inherited = [] + for fd in fds: + try: + st = os.fstat(fd) + except OSError as e: + if e.errno == errno.EBADF: + continue + raise + # Ignore Solaris door files + if not stat.S_ISDOOR(st.st_mode): + inherited.append(fd) + print(','.join(map(str, inherited))) |