diff options
author | Jeffrey Yasskin <jyasskin@gmail.com> | 2008-03-21 18:25:06 (GMT) |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@gmail.com> | 2008-03-21 18:25:06 (GMT) |
commit | 413f588a368a0bd612aed38c835eb4d8a0c1aaef (patch) | |
tree | 5fac5d34605a17f77f735ca5b13c66ced3af841c | |
parent | 859043c0538d9023515cac6900fe99f1edad0b75 (diff) | |
download | cpython-413f588a368a0bd612aed38c835eb4d8a0c1aaef.zip cpython-413f588a368a0bd612aed38c835eb4d8a0c1aaef.tar.gz cpython-413f588a368a0bd612aed38c835eb4d8a0c1aaef.tar.bz2 |
Try to fix test_signal on FreeBSD. I'm assuming that os.kill is failing to
raise a signal, but switching to subprocess makes the code cleaner anyway.
-rw-r--r-- | Lib/test/test_signal.py | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py index b0195d7..db15444 100644 --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -4,6 +4,7 @@ from contextlib import closing, nested import pickle import select import signal +import subprocess import traceback import sys, os, time, errno @@ -40,15 +41,13 @@ class InterProcessSignalTests(unittest.TestCase): print "handlerB invoked", args raise HandlerBCalled(*args) - def wait(self, child_pid): - """Wait for child_pid to finish, ignoring EINTR.""" + def wait(self, child): + """Wait for child to finish, ignoring EINTR.""" while True: try: - os.waitpid(child_pid, 0) + child.wait() return except OSError as e: - if e.errno == errno.ECHILD: - return if e.errno != errno.EINTR: raise @@ -69,35 +68,24 @@ class InterProcessSignalTests(unittest.TestCase): if test_support.verbose: print "test runner's pid is", pid - child = os.fork() - if child == 0: - os.kill(pid, signal.SIGHUP) - exit_subprocess() + child = subprocess.Popen(['kill', '-HUP', str(pid)]) self.wait(child) self.assertTrue(self.a_called) self.assertFalse(self.b_called) self.a_called = False try: - child = os.fork() - if child == 0: - os.kill(pid, signal.SIGUSR1) - exit_subprocess() + child = subprocess.Popen(['kill', '-USR1', str(pid)]) # This wait should be interrupted by the signal's exception. self.wait(child) self.fail('HandlerBCalled exception not thrown') except HandlerBCalled: - # So we call it again to reap the child's zombie. - self.wait(child) self.assertTrue(self.b_called) self.assertFalse(self.a_called) if test_support.verbose: print "HandlerBCalled exception caught" - child = os.fork() - if child == 0: - os.kill(pid, signal.SIGUSR2) - exit_subprocess() + child = subprocess.Popen(['kill', '-USR2', str(pid)]) self.wait(child) # Nothing should happen. try: |