[Python-Dev] Python signal processing question

Scott McCarty scott.mccarty at gmail.com
Mon Jul 19 19:09:36 CEST 2010


I apologize if this is the wrong place to ask questions about Python C code,
but I didn't know where else to turn. I don't think the regular user group
will be technical enough to find this, am I wrong?

There is no forum for something this in depth. This is not a usage problem,
I want to know where in the code this is happening, I understand how to use
these signals perfectly and why they are different. Clearly SIGKILL cannot
be caught and would never get used even if you did register that handler in
Python, while SIGTERM is able to be caught, this is standard Unix signals.
The part I am asking about is how python checks ahead of time. If it didn't
check (case before python 2.4), then it would get silently ignored because
the OS would kill the process without ever letting python even try and
handle that signal.

 I just want to understand the C/Python piece better because I am writing a
tutorial on signals and I am using python to demonstrate. I thought it would
be fun to show that the SIGKILL is never processed, but instead python
errors out. There is something in Python checking the SIGKILL signal
handler, while not checking SIGTERM and I can't find the Python C code that
handles it. When I am writing something like this, I like to point out the C
code, not just cite the documentation (I did find this change in behaviour
noted in the Python change log).

I will try and find a different list
Scott M

On Mon, Jul 19, 2010 at 12:27 PM, Oleg Broytman <phd at phd.pp.ru> wrote:

> Hello.
>
>   We'are sorry but we cannot help you. This mailing list is to work on
> developing Python (fixing bugs and adding new features to Python itself);
> if
> you're having problems using Python, please find another forum. Probably
> python-list (comp.lang.python) news group/mailing list is the best place.
> See http://www.python.org/community/ for other lists/news groups/fora.
> Thank you for understanding.
>
>   Regarding SIGKILL - read "man kill" carefully. Or better yet, a Unix
> programmer guide.
>
> On Mon, Jul 19, 2010 at 12:11:10PM -0400, Scott McCarty wrote:
> > All, I have searched everywhere (mostly the code and a little google) and
> I
> > cannot understand where the SIGKILL signal gets checked when it is set as
> a
> > handler. I have scoured the Modules/signalmodule.c only to find two
> > instances of the RuntimeError exception, but I cannot understand how
> python
> > knows when a handler is set for SIGKILL. I understand that this changed
> in
> > 2.4 and I am not trying to change it, I just really want to understand
> where
> > this happens. I used grep to find SIGKILL and SIGTERM to see if I could
> > determine where the critical difference is, but I cannot figure it out.
> >
> > I have about 2 hours of searching around and I can't figure it out, I
> assume
> > it has to rely on some default behaviour in Unix, but I have no idea. I
> > don't see a difference between SIGKILL and SIGTERM in the python code,
> but
> > obviously there is some difference. I understand what the difference is
> in
> > Unix/Linux, I just want to see it in the python code. Since python is
> > checking at run time to see what signals handlers are added, I know there
> > must be a difference.
> >
> > Please  can someone just point me in the right direction.
>
> Oleg.
> --
>     Oleg Broytman            http://phd.pp.ru/            phd at phd.pp.ru
>           Programmers don't die, they just GOSUB without RETURN.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20100719/35511cf5/attachment-0001.html>


More information about the Python-Dev mailing list