Re: Notifications when process is killed

2011-08-03 Thread chrisallick
On Aug 1, 5:56 am, Andrea Di Mario wrote: > Hi, i've created a twisted server application and i want that the > server send me a message when someone stops or kills the process. > I want to override reactor.stop(), but do this way send me message > when the process is stopped by a system kill? > C

Re: Notifications when process is killed

2011-08-03 Thread chrisallick
On Aug 1, 11:39 am, Andrea Di Mario wrote: > Thanks Thomas, it is what i'm looking for. > > Regards > > -- > Andrea Di Mario Catch a Kill: def signal_handler(signal, frame): print "Received exit command." #server.running = False sys.exit() signal.signal(signal.SIGINT, si

Re: Notifications when process is killed

2011-08-02 Thread Hansmeet Singh
you shouldn't have anything to worry about SIGTERM if you send out a SIGCHLD On Tue, Aug 2, 2011 at 3:44 AM, Chris Angelico wrote: > On Tue, Aug 2, 2011 at 11:36 AM, Andrea Di Mario > wrote: > > If i use SIGCHLD, i will have difficult when parent receive a SIGTERM, or > not? > > What you would

Re: Notifications when process is killed

2011-08-02 Thread Thomas Rachel
Am 02.08.2011 10:26 schrieb Thomas Rachel: Am 02.08.2011 09:30 schrieb AndDM: 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? SIGTERM cannot be caught - it kills the process the hard way. Tha

Re: Notifications when process is killed

2011-08-02 Thread Kushal Kumaran
On Tue, Aug 2, 2011 at 1:56 PM, Thomas Rachel wrote: > Am 02.08.2011 09:30 schrieb AndDM: > >> 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? > > SIGTERM cannot be caught - it kills the proce

Re: Notifications when process is killed

2011-08-02 Thread Chris Angelico
On Tue, Aug 2, 2011 at 11:36 AM, Andrea Di Mario wrote: > If i use SIGCHLD, i will have difficult when parent receive a SIGTERM, or not? What you would do is create two processes. Set up your signal handlers, then fork; in the parent, just watch for the child's death - in the child, do all your w

Notifications when process is killed

2011-08-02 Thread Andrea Di Mario
> 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

Re: Notifications when process is killed

2011-08-02 Thread Chris Angelico
On Tue, Aug 2, 2011 at 8:30 AM, AndDM 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) >        sign

Re: Notifications when process is killed

2011-08-02 Thread Thomas Rachel
Am 02.08.2011 09:30 schrieb AndDM: 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? SIGTERM cannot be caught - it kills the process the hard way. HTH, Thomas -- http://mail.python.org/mailman/

Re: Notifications when process is killed

2011-08-02 Thread AndDM
On Aug 1, 5:39 pm, Andrea Di Mario wrote: > Thanks Thomas, it is what i'm looking for. > > Regards > > -- > Andrea Di Mario Hi, i've a little problem, here the code that i use: def receive_signal(signum, stack): logging.info('Received: %s' % signum) reacto

Notifications when process is killed

2011-08-01 Thread Andrea Di Mario
Thanks Thomas, it is what i'm looking for. Regards -- Andrea Di Mario -- http://mail.python.org/mailman/listinfo/python-list

Re: Notifications when process is killed

2011-08-01 Thread Thomas Jollans
On 01/08/11 11:56, Andrea Di Mario wrote: > Hi, i've created a twisted server application and i want that the > server send me a message when someone stops or kills the process. > I want to override reactor.stop(), but do this way send me message > when the process is stopped by a system kill? > Co

Notifications when process is killed

2011-08-01 Thread Andrea Di Mario
Hi, i've created a twisted server application and i want that the server send me a message when someone stops or kills the process. I want to override reactor.stop(), but do this way send me message when the process is stopped by a system kill? Could you suggest me if there's a way to do this? Tha