This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jdemeyer
Recipients Rhamphoryncus, jdemeyer
Date 2019-04-11.10:40:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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)

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.
Date User Action Args
2019-04-11 10:40:13jdemeyersetrecipients: + jdemeyer, Rhamphoryncus
2019-04-11 10:40:13jdemeyersetmessageid: <>
2019-04-11 10:40:13jdemeyerlinkissue36601 messages
2019-04-11 10:40:12jdemeyercreate