New submission from Jeroen Demeyer <j.deme...@ugent.be>:
Because of some discussion that is happening on #1583 I noticed this bit of code in the OS-level signal handler (set by the C function sigaction() or signal()): static void signal_handler(int sig_num) { /* See NOTES section above */ if (getpid() == main_pid) { trip_signal(sig_num); } The check getpid() == main_pid is claimed to check for the main *thread* but in fact it's checking the process ID, which is the same for all threads. So as far as I can tell, this condition is always true. This code essentially goes back to 1994 (commit bb4ba12242), so it may have been true at that time that threads were implemented as processes and that getpid() returned a different value for different threads. Note that this code refers to receiving a signal from the OS. In Python, it's always handled (by the function registered by signal.signal) by the main thread. But the current behaviour actually makes sense, so we should just remove the superfluous check and fix the comments in the code. ---------- messages: 339958 nosy: Rhamphoryncus, jdemeyer priority: normal severity: normal status: open title: signals can be caught by any thread _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36601> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com