esharris has asked for the wisdom of the Perl Monks concerning the following question:

Suppose a Perl program modifies the time-out handler $SIG{ALRM}, sets the alarm to 4 minutes, and calls exit. The program never explicitly restores the time-out handler and it never explicitly turns off the alarm. Will Perl implicitly restore the time-out handler and implicitly turn off the alarm after the exit call? Or has the program created an orphaned process?

Replies are listed 'Best First'.
Re: unrestored signal handler after exit.
by sgifford (Prior) on Nov 19, 2003 at 18:03 UTC

    Signals and alarms are per-process, so when a process exits the kernel will automatically destroy its signal handler table, and will do the right thing with its alarms (either destroy them right then, or else let them go off and just ignore them).

    Perl doesn't need to do anything special; what happens is the same as if a C program had called signal and alarm.

Re: unrestored signal handler after exit.
by Abigail-II (Bishop) on Nov 19, 2003 at 17:58 UTC
    Well, what happened when you tried? Did an orphaned process get created? Did the alarm actually trigger? Where do you think the kernel delivers the signal?

    Abigail