multiprocessing and SIGINT

Gabriel Genellina gagsl-py2 at
Sat Jan 10 08:15:22 CET 2009

En Fri, 09 Jan 2009 03:04:58 -0200, akineko <akineko at> escribió:

> (2) test program with multiprocessing
> Both processes receives SIGINT.
> OS apparently distributes the SIGINT event to processes associated
> with the terminal.

Yes, to avoid that, the child process has to detach itself from the  
terminal. I'd expect the multiprocessing module to do that for us - but it  
doesn't. See

> (3) signal handler
> I realized that I could assign a signal handler specific to a process
> by placing it to a worker method.
> def worker():
>    # this process ignores SIGINT
>    signal.signal(signal.SIGINT, signal.SIG_IGN)
>    ... the rest ...

Looks fine...

> (4) terminating the spawned process
> I needed to send a shutdown message to the process via a communication
> between two processes.
> You can use Process.terminate() to brutally kill the process but that
> is a last resort.

What about sending a signal, like SIGTERM?

Gabriel Genellina

More information about the Python-list mailing list