diff options
author | Charles-François Natali <cf.natali@gmail.com> | 2013-08-25 16:27:59 (GMT) |
---|---|---|
committer | Charles-François Natali <cf.natali@gmail.com> | 2013-08-25 16:27:59 (GMT) |
commit | c20a7b977e919f1c261e955d3013ffae9ed0702f (patch) | |
tree | 92d3bdea9ae40a58fcd9ca91952ad26bb83c20c9 /Lib/test | |
parent | b33baf1c9f7b2d811ef53f48988aa5d8403bd884 (diff) | |
parent | 249cdc39fcfb0405ccb2c952f5d8bfce77deb53d (diff) | |
download | cpython-c20a7b977e919f1c261e955d3013ffae9ed0702f.zip cpython-c20a7b977e919f1c261e955d3013ffae9ed0702f.tar.gz cpython-c20a7b977e919f1c261e955d3013ffae9ed0702f.tar.bz2 |
Merge.
Diffstat (limited to 'Lib/test')
-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 0aa4d21..f8cd1de 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1938,6 +1938,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): |