Martin Panter added the comment:
This works for me on Linux:
>>> signal.pthread_sigmask(signal.SIG_BLOCK, {signal.SIGUSR1})
set()
>>> import threading
>>> t = threading.Thread(target=sigwait)
>>> t.start()
Send me a signal, my PID is 24197
>>> os.kill(os.getpid(), signal.SIGUSR1)
Got the signal: 10
>>> t.join()
Posix <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sigwait.html>
only defines sigwait() if the signals are already blocked. Two reasons behind
this come to mind:
1. There would be a race where the signal handler may be called first (or the
signal may be ignored) at the OS level, and the sigwait() function will miss
the signal and block.
2. If the signal is handled in the context of another thread that isn’t using
sigwait(), it may be consumed (handled or ignored) in the context of the other
thread, with no effect on your sigwait() call.
This detail of blocking the signal seems to be a common error, so maybe the
Python documentation could help point it out. (Issue 25868 comes to mind; there
is a test case that IMO should block a signal before waiting for it.)
----------
nosy: +martin.panter
versions: -Python 3.4
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue29374>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com