summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2013-08-29 20:39:44 (GMT)
committerGregory P. Smith <greg@krypto.org>2013-08-29 20:39:44 (GMT)
commit6cc50391a600b010d3cdc944d5355c93654da43f (patch)
tree8b60055f9cb07ba6956d0450a62f21df7626cc43 /Lib/test/test_subprocess.py
parent2f43d07454794cc0b91593d4a03423c94d935a13 (diff)
parentdee0434e2fb030df448770199627e87c9e06a6bf (diff)
downloadcpython-6cc50391a600b010d3cdc944d5355c93654da43f.zip
cpython-6cc50391a600b010d3cdc944d5355c93654da43f.tar.gz
cpython-6cc50391a600b010d3cdc944d5355c93654da43f.tar.bz2
Fixes Issue #15507: test_subprocess's test_send_signal could fail if the test
runner were run in an environment where the process inherited an ignore setting for SIGINT. Restore the SIGINT handler to the desired KeyboardInterrupt raising one during that test.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 8cd2d1e..b1c091e 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -1432,16 +1432,22 @@ class POSIXProcessTestCase(BaseTestCase):
def _kill_process(self, method, *args):
# Do not inherit file handles from the parent.
# It should fix failures on some platforms.
- p = subprocess.Popen([sys.executable, "-c", """if 1:
- import sys, time
- sys.stdout.write('x\\n')
- sys.stdout.flush()
- time.sleep(30)
- """],
- close_fds=True,
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ # Also set the SIGINT handler to the default to make sure it's not
+ # being ignored (some tests rely on that.)
+ old_handler = signal.signal(signal.SIGINT, signal.default_int_handler)
+ try:
+ p = subprocess.Popen([sys.executable, "-c", """if 1:
+ import sys, time
+ sys.stdout.write('x\\n')
+ sys.stdout.flush()
+ time.sleep(30)
+ """],
+ close_fds=True,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ finally:
+ signal.signal(signal.SIGINT, old_handler)
# Wait for the interpreter to be completely initialized before
# sending any signal.
p.stdout.read(1)