properly catch SIGTERM

Oscar Benjamin oscar.benjamin at
Fri Jul 20 19:18:52 CEST 2012

What about Kushal's suggestion above? Does the following work for you?

signal.signal(signal.SIGTERM, my_SIGTERM_handler)
signal.siginterrupt(signal.SIGTERM, flag=False)

According to the siginterrupt docs (
Change system call restart behaviour: if flag is False, system calls will
be restarted when interrupted by signal signalnum, otherwise system calls
will be interrupted. Returns nothing. Availability: Unix

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list