summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorCharles-François Natali <cf.natali@gmail.com>2013-08-25 16:27:59 (GMT)
committerCharles-François Natali <cf.natali@gmail.com>2013-08-25 16:27:59 (GMT)
commitc20a7b977e919f1c261e955d3013ffae9ed0702f (patch)
tree92d3bdea9ae40a58fcd9ca91952ad26bb83c20c9 /Lib
parentb33baf1c9f7b2d811ef53f48988aa5d8403bd884 (diff)
parent249cdc39fcfb0405ccb2c952f5d8bfce77deb53d (diff)
downloadcpython-c20a7b977e919f1c261e955d3013ffae9ed0702f.zip
cpython-c20a7b977e919f1c261e955d3013ffae9ed0702f.tar.gz
cpython-c20a7b977e919f1c261e955d3013ffae9ed0702f.tar.bz2
Merge.
Diffstat (limited to 'Lib')
-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 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):