mhearse has asked for the wisdom of the Perl Monks concerning the following question:
Signal SIGTERM received, but no signal handler set.
### $q will be used as a queue to store the output my $q = new Thread::Queue; ### $inotify_pid will be hold the pid of the inotifywait thread. my $inotify_pid : shared; ### Run inotifywait as a thread. my $inotify_thread = async { \&inotifywait(), $q, $inotify_pid }; usleep 50; ### Run keepalive as a thread. my $keepalive_thread = async { \&keepalive() }; usleep 50; ### Install master signal handler to cleanup before we exit. $SIG{'TERM'} = sub { debug(qq{Caught signal: INT.\n}); $keepalive_thread->kill('INT'); $keepalive_thread->join(); kill 9, $inotify_pid; $inotify_thread->join(); exit; }; process_output(); ################################################################# sub keepalive { ################################################################# $SIG{'INT'} = sub { threads->exit(); }; while (1) { ### Check to see if inotifywait thread is still running. ### If not, we restart it. if (!$inotify_thread->is_running()) { debug(qq{Inotifywait thread not running.\n}); kill 9, $inotify_pid; $inotify_thread->join(); $inotify_thread = async { \&inotifywait(), $q, $inotify_pi +d }; } usleep 50; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Thread signal handlers: keepalive issue
by zentara (Cardinal) on Jul 19, 2008 at 11:11 UTC |