Avoid nested SIGINT handling

Mladen Gogala mgogala at yahoo.com
Sat Nov 13 00:13:20 EST 2021


On Thu, 11 Nov 2021 17:22:15 +1100, Chris Angelico wrote:

> Threads aren't the point here - signals happen immediately.

Actually, signals are not delivered immediately. Signals are delivered 
the next time the process gets its turn on CPU. The process scheduler 
will make process runnable and the process will check for any pending 
signals first and will execute the handler. It is possible to have 
several SIGINT signals pending, for instance when I nervously press ctrl-
C several times. However, signals are not processed as a part of the 
normal flow of the process and are processed sequentially.. When the 
process finds a pending signal, it executes the registered signal 
handler. It's always the same signal handler, unless signal handler is 
changed within the signal handler. After the signals are delivered, the 
process continues its normal operation until its CPU quantum expires or 
until initiates a synchronous I/O operation, as is the case with all 
normal read operations.
BTW, that's the case on both Unix/Linux systems and Windows systems.



-- 
Mladen Gogala
Database Consultant
https://dbwhisperer.wordpress.com


More information about the Python-list mailing list