/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. }
In reply to Re: Gracefully exiting daemons
by Brovnik
in thread Gracefully exiting daemons
by asiufy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |