Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10702

Re: Notifications when process is killed

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:process': 0.07; 'subject:when': 0.07; 'am,': 0.13; 'wrote:': 0.15; 'ends,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'ideas?': 0.16; 'parameters,': 0.16; '\xa0def': 0.16; 'aug': 0.19; 'received:209.85.210.174': 0.19; 'received:mail- iy0-f174.google.com': 0.19; "doesn't": 0.22; 'header:In-Reply- To:1': 0.22; 'end,': 0.23; 'reason,': 0.23; 'tue,': 0.23; 'code': 0.24; 'function': 0.26; 'tried': 0.27; 'message- id:@mail.gmail.com': 0.28; 'parent': 0.30; "won't": 0.32; 'chris': 0.32; 'skip:\xa0 30': 0.32; "i've": 0.33; 'to:addr:python-list': 0.34; '8bit%:3': 0.35; 'option.': 0.35; 'anything': 0.37; 'some': 0.37; 'but': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'signal': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.40; 'skip:r 20': 0.40; 'subject:skip:N 10': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=D1fJMvKn8AVXONiL/CbU43mdJ4PrsRg4qN9DEWKEH8M=; b=Vj+tg233VDgJNW60MXW5MDRqXl7m57YQzoW5whUfUn92y3rMrJohJu81zJjVxUiX8H fn7CJSYDntqTDo2MwovbTWW7w2LUhBSSEjAKdIFBTsSKVcptmX15aEL8n0t8J0hCfUjq LvEv24PALN9Q6vIWWPUc0zVYiUtDBAhmaWfZ4=
MIME-Version 1.0
In-Reply-To <a4209f40-8bac-48e5-9092-3cf9d68055ef@g2g2000vbl.googlegroups.com>
References <mailman.1730.1312213173.1164.python-list@python.org> <a4209f40-8bac-48e5-9092-3cf9d68055ef@g2g2000vbl.googlegroups.com>
Date Tue, 2 Aug 2011 10:01:26 +0100
Subject Re: Notifications when process is killed
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1752.1312275689.1164.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1312275689 news.xs4all.nl 23946 [2001:888:2000:d::a6]:52054
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10702

Show key headers only | View raw


On Tue, Aug 2, 2011 at 8:30 AM, AndDM <anddimario@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Notifications when process is killed Andrea Di Mario <anddimario@gmail.com> - 2011-08-01 17:39 +0200
  Re: Notifications when process is killed AndDM <anddimario@gmail.com> - 2011-08-02 00:30 -0700
    Re: Notifications when process is killed Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-08-02 10:26 +0200
      Re: Notifications when process is killed Kushal Kumaran <kushal.kumaran+python@gmail.com> - 2011-08-02 16:45 +0530
      Re: Notifications when process is killed Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-08-02 13:40 +0200
    Re: Notifications when process is killed Chris Angelico <rosuav@gmail.com> - 2011-08-02 10:01 +0100
  Re: Notifications when process is killed chrisallick <chrisallick@gmail.com> - 2011-08-03 20:41 -0700

csiph-web