in reply to Re: protect children from SIG{INT}
in thread protect children from SIG{INT}
I was able to interrupt that with CTRL-C, even though I ignored SIGINT in the child process.$SIG{INT} = $SIG{HUP} = sub {}; exec qw(/bin/sleep 5) or die 'exec failed';
Update: Well, the above apparently worked for the OP, though it still doesn't work for me. Maybe it's OS-dependent; I'm testing on Linux.
Update: Kudos to pileofrogs for pointing out below that setting the signal handlers to the string IGNORE works perfectly! It seems that the signal mask persists across an exec, but signal handlers don't, which basically makes sense. So this code works on my system:
$SIG{INT} = $SIG{HUP} = 'IGNORE'; exec qw(sleep 5) or die 'exec failed';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: protect children from SIG{INT}
by Zaxo (Archbishop) on Nov 18, 2005 at 09:13 UTC | |
by QM (Parson) on Nov 18, 2005 at 15:12 UTC | |
by sgifford (Prior) on Nov 18, 2005 at 16:18 UTC | |
|
Re^3: protect children from SIG{INT}
by pileofrogs (Priest) on Nov 18, 2005 at 16:57 UTC |