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: Julien Dessaux
Subject: Re: Odd behaviour when running exec inside a signal handler
Date: Mon, 26 Jul 2010 15:12:23 +0200

On Mon, Jul 26, 2010 at 2:16 PM, Greg Wooledge <wooledg@eeg.ccf.org> wrote:

> On Sun, Jul 25, 2010 at 04:54:53PM -0400, Chet Ramey wrote:
> > On 7/25/10 8:51 AM, Julien Dessaux wrote:
> > >     I have a script that trap USR1 for reloading purpose. The signal
> handler
> > > then does some cleaning, then exec $0.
> >
> > 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.
>
> I believe the typical workaround for this type of issue is to set a
> variable in the signal handler, and then (outside the trap, in some sort
> of main loop) check for that variable and do the real handling.
>
> I've never developed a bash script that needed that sort of sophistication,
> but that's how it's generally done in C.
>

I really didn't believed it would just appear to be a posix issue! I guess I
am trying to do something that is really too ugly...

Anyway, thank you both.
--
Julien Dessaux


reply via email to

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