diff options
author | Charles-Fran?ois Natali <cf.natali@gmail.com> | 2013-08-25 18:28:44 +0200 |
---|---|---|
committer | Charles-Fran?ois Natali <cf.natali@gmail.com> | 2013-08-25 18:28:44 +0200 |
commit | 0da8dc3892f2ca0a378ddf22d2ae47b3aa631923 (patch) | |
tree | 38ad8999260c2535df6cc6aa521c3b4bc750043a /Lib/test/test_subprocess.py | |
parent | 539264c48a4294b16f8e941f82601d90a2193478 (diff) | |
parent | 2e9e17f6d90d9c96efe0489608dd39e5f80b2984 (diff) | |
download | cpython-0da8dc3892f2ca0a378ddf22d2ae47b3aa631923.tar.gz |
Merge.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r-- | Lib/test/test_subprocess.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 470faff3c7..8a3ac4bae7 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1972,6 +1972,23 @@ class POSIXProcessTestCase(BaseTestCase): self.assertRaises(OSError, os.waitpid, pid, 0) self.assertNotIn(ident, [id(o) for o in subprocess._active]) + def test_close_fds_after_preexec(self): + fd_status = support.findfile("fd_status.py", subdir="subprocessdata") + + # this FD is used as dup2() target by preexec_fn, and should be closed + # in the child process + fd = os.dup(1) + self.addCleanup(os.close, fd) + + p = subprocess.Popen([sys.executable, fd_status], + stdout=subprocess.PIPE, close_fds=True, + preexec_fn=lambda: os.dup2(1, fd)) + output, ignored = p.communicate() + + remaining_fds = set(map(int, output.split(b','))) + + self.assertNotIn(fd, remaining_fds) + @unittest.skipUnless(mswindows, "Windows specific tests") class Win32ProcessTestCase(BaseTestCase): |