cpython: f8c49a930015 (original) (raw)

Mercurial > cpython

changeset 69935:f8c49a930015

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. [#8407]

Victor Stinner victor.stinner@haypocalc.com
date Sun, 08 May 2011 02:03:15 +0200
parents 1d8a57deddc4
children e3cb2c99a5a9
files Doc/library/signal.rst Doc/whatsnew/3.3.rst Lib/test/test_signal.py Misc/NEWS Modules/signalmodule.c
diffstat 5 files changed, 35 insertions(+), 5 deletions(-)[+] [-] Doc/library/signal.rst 10 Doc/whatsnew/3.3.rst 4 Lib/test/test_signal.py 15 Misc/NEWS 4 Modules/signalmodule.c 7

line wrap: on

line diff

--- a/Doc/library/signal.rst +++ b/Doc/library/signal.rst @@ -262,13 +262,17 @@ The :mod:signal module defines the fol .. function:: set_wakeup_fd(fd)

--- a/Doc/whatsnew/3.3.rst +++ b/Doc/whatsnew/3.3.rst @@ -131,6 +131,10 @@ signal

--- 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.TestCas TIMEOUT_FULL = 10 TIMEOUT_HALF = 5

+ def test_wakeup_fd_early(self): import select @@ -249,6 +255,7 @@ class WakeupSignalTests(unittest.TestCas select.select([self.read], [], [], self.TIMEOUT_FULL) after_time = time.time() self.assertTrue(after_time - mid_time < self.TIMEOUT_HALF)

def test_wakeup_fd_during(self): import select @@ -260,6 +267,14 @@ class WakeupSignalTests(unittest.TestCas [self.read], [], [], self.TIMEOUT_FULL) after_time = time.time() self.assertTrue(after_time - before_time < self.TIMEOUT_HALF)

+

def setUp(self): import fcntl

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -140,6 +140,10 @@ Core and Builtins Library ------- +- Issue #8407: The signal handler writes the signal number as a single byte

--- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -176,6 +176,7 @@ checksignals_witharg(void * unused) static void trip_signal(int sig_num) {

@@ -183,8 +184,10 @@ trip_signal(int sig_num) cleared in PyErr_CheckSignals() before .tripped. */ is_tripped = 1; Py_AddPendingCall(checksignals_witharg, NULL);

} static void