bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Odd behaviour when running exec inside a signal handler


From: Chet Ramey
Subject: Re: Odd behaviour when running exec inside a signal handler
Date: Sun, 25 Jul 2010 16:54:53 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.7) Gecko/20100111 Lightning/1.0b1 Thunderbird/3.0.1

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    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]