Issue #8407, issue #11859: Add signal.pthread_sigmask() function to fetch

and/or change the signal mask of the calling thread.

Fix also tests of test_io using threads and an alarm: use pthread_sigmask() to
ensure that the SIGALRM signal is received by the main thread.

Original patch written by Jean-Paul Calderone.
This commit is contained in:
Victor Stinner 2011-04-30 15:21:58 +02:00
parent d5c355ccc7
commit a929335961
6 changed files with 262 additions and 6 deletions

View file

@ -2627,6 +2627,8 @@ class SignalsTest(unittest.TestCase):
in the latter."""
read_results = []
def _read():
if hasattr(signal, 'pthread_sigmask'):
signal.pthread_sigmask(signal.SIG_BLOCK, [signal.SIGALRM])
s = os.read(r, 1)
read_results.append(s)
t = threading.Thread(target=_read)