in reply to Gracefully exiting daemons
/etc/init.d (on many unixes) will have examples of start/stop scripts. Stopping is often done by signalling using a stored Process ID, so the $SIG{INT} handler handles both unexpected kills and 'normal' kills e.g. from a shutdon command.#... $SIG{'INT'} = 'cleanup'; # we want to rewind tape & write to log $SIG{'HUP'} = 'cleanup'; # we want to rewind tape & write to log # later... sub cleanup { # Normal is set to true if the script has got through the # rest. &report("\nAbnormal exit, cleaning up") unless $normal; if ($normal) { &eject(); } else { &rewind(); &eject() if $opt{e}; } # Report and other stuff here deleted. }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Gracefully exiting daemons
by asiufy (Monk) on Jun 25, 2001 at 22:02 UTC | |
by Brovnik (Hermit) on Jun 26, 2001 at 02:32 UTC |