On Tue, Aug 2, 2011 at 8:30 AM, AndDM <anddima...@gmail.com> wrote:
>        def receive_signal(signum, stack):
>                logging.info('Received: %s' % signum)
>                reactor.stop()
>        signal.signal(signal.SIGTERM, receive_signal)
>        signal.signal(signal.SIGHUP, receive_signal)
>        signal.signal(signal.SIGINT, receive_signal)
>
> The function works for SIGHUP and SIGINT, but it doesn't work for
> SIGTERM. I've tried with simple killall and with -15 option.
> Have you some ideas?

You won't be able to catch SIGTERM, as Thomas said, but if you need to
know what caused a process to end, the best way is to have code in the
parent process to catch SIGCHLD. When the child ends, for any reason,
its parent is sent SIGCHLD with some parameters, including the signal
number that caused the termination; you can then log anything you
want.

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to