summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-08 00:03:15 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-08 00:03:15 (GMT)
commitd49b1f14de90ce31bb0777ac232c0ee1ec5ed6ce (patch)
treea201ad26f808cf4d1cefa8f57fe397e88d1afc77 /Lib/test
parentb3e7219abfdb52321b7e8f1f57499ece23a7d2f8 (diff)
downloadcpython-d49b1f14de90ce31bb0777ac232c0ee1ec5ed6ce.zip
cpython-d49b1f14de90ce31bb0777ac232c0ee1ec5ed6ce.tar.gz
cpython-d49b1f14de90ce31bb0777ac232c0ee1ec5ed6ce.tar.bz2
Issue #8407: The signal handler writes the signal number as a single byte
instead of a nul byte into the wakeup file descriptor. So it is possible to wait more than one signal and know which signals were raised.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_signal.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
index c1054ed..80b9744 100644
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -5,6 +5,7 @@ import gc
import pickle
import select
import signal
+import struct
import subprocess
import traceback
import sys, os, time, errno
@@ -236,6 +237,11 @@ class WakeupSignalTests(unittest.TestCase):
TIMEOUT_FULL = 10
TIMEOUT_HALF = 5
+ def check_signum(self, *signals):
+ data = os.read(self.read, len(signals)+1)
+ raised = struct.unpack('%uB' % len(data), data)
+ self.assertSequenceEqual(raised, signals)
+
def test_wakeup_fd_early(self):
import select
@@ -249,6 +255,7 @@ class WakeupSignalTests(unittest.TestCase):
select.select([self.read], [], [], self.TIMEOUT_FULL)
after_time = time.time()
self.assertTrue(after_time - mid_time < self.TIMEOUT_HALF)
+ self.check_signum(signal.SIGALRM)
def test_wakeup_fd_during(self):
import select
@@ -260,6 +267,14 @@ class WakeupSignalTests(unittest.TestCase):
[self.read], [], [], self.TIMEOUT_FULL)
after_time = time.time()
self.assertTrue(after_time - before_time < self.TIMEOUT_HALF)
+ self.check_signum(signal.SIGALRM)
+
+ def test_signum(self):
+ old_handler = signal.signal(signal.SIGUSR1, lambda x,y:None)
+ self.addCleanup(signal.signal, signal.SIGUSR1, old_handler)
+ os.kill(os.getpid(), signal.SIGUSR1)
+ os.kill(os.getpid(), signal.SIGALRM)
+ self.check_signum(signal.SIGUSR1, signal.SIGALRM)
def setUp(self):
import fcntl