mirror of
https://github.com/python/cpython.git
synced 2025-10-03 13:45:29 +00:00
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.
This commit is contained in:
commit
6cc50391a6
2 changed files with 21 additions and 10 deletions
|
@ -1432,16 +1432,22 @@ class POSIXProcessTestCase(BaseTestCase):
|
||||||
def _kill_process(self, method, *args):
|
def _kill_process(self, method, *args):
|
||||||
# Do not inherit file handles from the parent.
|
# Do not inherit file handles from the parent.
|
||||||
# It should fix failures on some platforms.
|
# It should fix failures on some platforms.
|
||||||
p = subprocess.Popen([sys.executable, "-c", """if 1:
|
# Also set the SIGINT handler to the default to make sure it's not
|
||||||
import sys, time
|
# being ignored (some tests rely on that.)
|
||||||
sys.stdout.write('x\\n')
|
old_handler = signal.signal(signal.SIGINT, signal.default_int_handler)
|
||||||
sys.stdout.flush()
|
try:
|
||||||
time.sleep(30)
|
p = subprocess.Popen([sys.executable, "-c", """if 1:
|
||||||
"""],
|
import sys, time
|
||||||
close_fds=True,
|
sys.stdout.write('x\\n')
|
||||||
stdin=subprocess.PIPE,
|
sys.stdout.flush()
|
||||||
stdout=subprocess.PIPE,
|
time.sleep(30)
|
||||||
stderr=subprocess.PIPE)
|
"""],
|
||||||
|
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
|
# Wait for the interpreter to be completely initialized before
|
||||||
# sending any signal.
|
# sending any signal.
|
||||||
p.stdout.read(1)
|
p.stdout.read(1)
|
||||||
|
|
|
@ -155,6 +155,11 @@ Library
|
||||||
Tests
|
Tests
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
- 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.
|
||||||
|
|
||||||
- Issue #16799: Switched from getopt to argparse style in regrtest's argument
|
- Issue #16799: Switched from getopt to argparse style in regrtest's argument
|
||||||
parsing. Added more tests for regrtest's argument parsing.
|
parsing. Added more tests for regrtest's argument parsing.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue