Fix signal handler in test.

This commit is contained in:
Richard Oudkerk 2013-10-17 15:22:10 +01:00
parent 240f86d7dd
commit cc5c728513
1 changed files with 5 additions and 1 deletions

View File

@ -354,12 +354,16 @@ class _TestProcess(BaseTestCase):
else:
os.kill(pid, signal.SIGTERM)
def handler(*args):
raise RuntimeError('join took too long: %s' % p)
raise RuntimeError('waitpid() took too long')
old_handler = signal.signal(signal.SIGALRM, handler)
try:
signal.alarm(10)
pid_status = os.waitpid(pid, 0)
self.assertEqual(pid_status[0], pid)
except RuntimeError:
print('os.waitpid() =',
os.waitpid(pid, os.WNOHANG), file=sys.stderr)
raise
finally:
signal.alarm(0)
signal.signal(signal.SIGALRM, old_handler)