Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 May 2009 11:24:22 -0700
From:      Chuck Swiger <cswiger@mac.com>
To:        Peter Steele <psteele@maxiscale.com>
Cc:        #freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Re: Why would a kill -2 not work?
Message-ID:  <0FC07847-8AEB-4728-8DAB-2F7FD2186E29@mac.com>
In-Reply-To: <7097313.721242663800853.JavaMail.HALO$@halo>
References:  <7097313.721242663800853.JavaMail.HALO$@halo>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi--

On May 18, 2009, at 9:23 AM, Peter Steele wrote:
> Under what circumstances might a "kill -2 nnn" not work. I have a  
> Python app with a signal handler configured to catch INT signals. It  
> seems to work fine, but we've recently noticed that after the app  
> has run for a while the kill -2 no longer works. This seems pretty  
> suspicious, perhaps indicating our app is misbehaving in some way.  
> What might cause the signal handler to stop working?

The main reason might be that your process is already in another  
signal handler or is otherwise blocked in a system call and won't get  
the new signal until it completes the current situation.

The amount of stuff you're allowed to do safely in a signal handler is  
pretty minimal-- you're better off setting a flag, returning from the  
signal handler, and having the next run past the main event loop or  
whatever check for the flag and handle things in a normal app  
context.  If you try to do anything involving malloc() or s/printf,  
etc, you're running risks.  "man sigaction" is likely to be  
informative....

Regards,
-- 
-Chuck




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0FC07847-8AEB-4728-8DAB-2F7FD2186E29>