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 eryksun
Recipients Ross Rosen, eric.araujo, eryksun, ezio.melotti, giampaolo.rodola, mdk, paul.moore, steve.dower, tim.golden, vstinner, willingc, zach.ware
Date 2021-03-20.03:49:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616212198.41.0.5779542429.issue26350@roundup.psfhosted.org>
In-reply-to
Content
The signal.signal() docs should explain that only SIGINT and SIGBREAK can be signaled from another process, and only if the current process is a console application. A link to os.kill() could be added, which should explain their use as signals in relation to console control events. Also, setting a handler for SIGABRT, SIGFPE, SIGILL, and SIGSEGV should be discouraged in the documentation because they are not compatible with how Python handles signals by tripping a flag for deferred processing on the main thread.

The design of os.kill() in Windows has some unfortunate mistakes, but it needs to be better documented at least. It should explain that the pid value, when used with CTRL_C_EVENT and CTRL_BREAK_EVENT, is a process-group ID, not a process ID. It should explain that CTRL_C_EVENT will be ignored by a process in the target group if the process calls SetConsoleCtrlHandler(NULL, TRUE), or if it's started with Ctrl+C ignored either due to inheritance or due to being created in a new process group. It should explain that these console control events get mapped to the C signals SIGINT and SIGBREAK. 

Also the line "[t]he Windows version of kill() additionally takes process handles to be killed" needs to removed. os.kill() has never accepted handles in addition to PIDs. Implementing that reliably would require an additional parameter.

---

Ideally, the code path in os.kill() that generates a console control event would have been reserved for a negative PID value (i.e. a process group ID), with -1 reserved to send the event to all processes in the console session (i.e. console process group 0). Also, in this case, os.kill() would use SIGINT and SIGBREAK instead of WinAPI CTRL_C_EVENT and CTRL_BREAK_EVENT. Such a design would have conformed much better with POSIX kill().
History
Date User Action Args
2021-03-20 03:49:58eryksunsetrecipients: + eryksun, paul.moore, vstinner, giampaolo.rodola, tim.golden, ezio.melotti, eric.araujo, zach.ware, steve.dower, willingc, mdk, Ross Rosen
2021-03-20 03:49:58eryksunsetmessageid: <1616212198.41.0.5779542429.issue26350@roundup.psfhosted.org>
2021-03-20 03:49:58eryksunlinkissue26350 messages
2021-03-20 03:49:58eryksuncreate