in reply to Re^3: protect children from SIG{INT}
in thread protect children from SIG{INT}
Hitting CTRL-C kills the process, and doesn't print Sleep is done, as it would if it had completed normally.#!/usr/bin/perl $SIG{INT} = $SIG{HUP} = sub {}; exec 'perl', '-e', '$span=5; $span -= sleep $span while $span > 0; warn "Sleep is done\n";' or die 'exec failed';
Of course, using do instead would work, because it would avoid the exec.
Does it even make sense for a signal handler to persist across an exec? A signal handler is basically an address in memory that the kernel should cause the user process to jump to if a signal arrives, but after an exec the address space will change, and the old address will almost certainly not be a sane place to jump to.
|
|---|