summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorTim Golden <mail@timgolden.me.uk>2010-08-06 13:20:12 (GMT)
committerTim Golden <mail@timgolden.me.uk>2010-08-06 13:20:12 (GMT)
commit40b3744efa2572ce429771d6971f7972a12c2405 (patch)
tree2df2b7c9efee984171de20b9d2d6997324fe0df9 /Lib/test/test_subprocess.py
parent51ced7afe72d861b46f069d757f2787f13253d32 (diff)
downloadcpython-40b3744efa2572ce429771d6971f7972a12c2405.zip
cpython-40b3744efa2572ce429771d6971f7972a12c2405.tar.gz
cpython-40b3744efa2572ce429771d6971f7972a12c2405.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 5cdbe2d..ff9945b 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -548,6 +548,26 @@ class ProcessTestCase(unittest.TestCase):
output = subprocess.check_output([sys.executable, '-c', code])
self.assert_(output.startswith(b'Hello World!'), ascii(output))
+ def test_handles_closed_on_exception(self):
+ # If CreateProcess exits with an error, ensure the
+ # duplicate output handles are released
+ ifhandle, ifname = self.mkstemp()
+ ofhandle, ofname = self.mkstemp()
+ efhandle, efname = self.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))
+
#
# POSIX tests
#