summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorTim Golden <mail@timgolden.me.uk>2010-08-06 13:14:33 (GMT)
committerTim Golden <mail@timgolden.me.uk>2010-08-06 13:14:33 (GMT)
commit90374f510223f559a70dcd762e223762d4f2ad85 (patch)
tree7557d5f2745bb82c9e9e394cfe5fb7f7d2304a66 /Lib/test/test_subprocess.py
parent3ad323ecaf9bbead043a8799d0a6189c6812b581 (diff)
downloadcpython-90374f510223f559a70dcd762e223762d4f2ad85.zip
cpython-90374f510223f559a70dcd762e223762d4f2ad85.tar.gz
cpython-90374f510223f559a70dcd762e223762d4f2ad85.tar.bz2
Issue #3210: Ensure stdio handles are closed if CreateProcess fails
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index adfb1bf..15ca1975 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -533,6 +533,26 @@ class ProcessTestCase(BaseTestCase):
if c.exception.errno != 2: # ignore "no such file"
raise c.exception
+ def test_handles_closed_on_exception(self):
+ # If CreateProcess exits with an error, ensure the
+ # duplicate output handles are released
+ ifhandle, ifname = mkstemp()
+ ofhandle, ofname = mkstemp()
+ efhandle, efname = mkstemp()
+ try:
+ subprocess.Popen (["*"], stdin=ifhandle, stdout=ofhandle,
+ stderr=efhandle)
+ except OSError:
+ os.close(ifhandle)
+ os.remove(ifname)
+ os.close(ofhandle)
+ os.remove(ofname)
+ os.close(efhandle)
+ os.remove(efname)
+ self.assertFalse(os.path.exists(ifname))
+ self.assertFalse(os.path.exists(ofname))
+ self.assertFalse(os.path.exists(efname))
+
# context manager
class _SuppressCoreFiles(object):