summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-02-14 17:04:26 (GMT)
committerGeorg Brandl <georg@python.org>2009-02-14 17:04:26 (GMT)
commit78162daff670696e64d570ed070fbda33b25890d (patch)
tree13094b4e1914fd672442e9197eac2f65e0a1d4c5 /Lib/test/test_subprocess.py
parent02bdf93b85e168f2b9015f1a59fc2487acba0e01 (diff)
downloadcpython-78162daff670696e64d570ed070fbda33b25890d.zip
cpython-78162daff670696e64d570ed070fbda33b25890d.tar.gz
cpython-78162daff670696e64d570ed070fbda33b25890d.tar.bz2
Merged revisions 69620 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r69620 | georg.brandl | 2009-02-14 18:01:36 +0100 (Sa, 14 Feb 2009) | 1 line #5179: don't leak PIPE fds when child execution fails. ........
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index e7ba26f..99f31b9 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -486,6 +486,22 @@ class ProcessTestCase(unittest.TestCase):
else:
self.fail("Expected TypeError")
+ def test_leaking_fds_on_error(self):
+ # see bug #5179: Popen leaks file descriptors to PIPEs if
+ # the child fails to execute; this will eventually exhaust
+ # the maximum number of open fds. 1024 seems a very common
+ # value for that limit, but Windows has 2048, so we loop
+ # 1024 times (each call leaked two fds).
+ for i in range(1024):
+ try:
+ subprocess.Popen(['nonexisting_i_hope'],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ # Windows raises IOError
+ except (IOError, OSError), err:
+ if err.errno != 2: # ignore "no such file"
+ raise
+
#
# POSIX tests
#