On 7/25/10 8:51 AM, Julien Dessaux wrote:
> Hi,
> 
>     I found a very odd behaviour in bash. It's about a problem I encounter
> when I do a exec from the inside of a signal handler. I can reproduce 100%
> sure on my bash 4.0.35 on OpenBSD, and on a bash 4.1.7 on archlinux, and
> people on #bash seem to agree with me.
> 
>     I have a script that trap USR1 for reloading purpose. The signal handler
> then does some cleaning, then exec $0. The script then reloads itself and
> rearm the signal. The problem is that the script will never be able to catch
> a USR1 signal again, that's really just as if bash believes we never got out
> of the previous handler.

With BSD and Posix-style signals, the caught signal is automatically
blocked by the kernel when executing its signal handler.  If you exec
a new program out of the signal handler, it's going to be executed
with that signal blocked.  From the new program's perspective, it really
is as if you never left the signal handler.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to