summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorCharles-François Natali <cf.natali@gmail.com>2013-08-25 16:28:44 (GMT)
committerCharles-François Natali <cf.natali@gmail.com>2013-08-25 16:28:44 (GMT)
commita439b32cf02a78ca326d131897c3e5b1883210f2 (patch)
tree733ee396bac4e2299ae23a13c5e1dee98deef9ed /Lib/test/test_subprocess.py
parent58b3ebfab92d4241e65fbb0f34c84746fcbe347b (diff)
parentc20a7b977e919f1c261e955d3013ffae9ed0702f (diff)
downloadcpython-a439b32cf02a78ca326d131897c3e5b1883210f2.zip
cpython-a439b32cf02a78ca326d131897c3e5b1883210f2.tar.gz
cpython-a439b32cf02a78ca326d131897c3e5b1883210f2.tar.bz2
Merge.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 470faff..8a3ac4b 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):