nutris has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I am trying to use AnyEvent to handle signals (SIGHUP, SIGTERM, etc.). I think a I have to use AnyEvent since I need the process to listen to signals and filesystem events (via AnyEvent::Filesys::Notify).
According to the documentation at http://search.cpan.org/~mlehmann/AnyEvent-5.34/lib/AnyEvent.pm#SIGNAL_WATCHERS I am trying the following:
#!/usr/bin/perl use strict; use warnings; use AnyEvent; # set up event handler my $w = AnyEvent->signal (signal => "HUP", cb => sub { print "Got SIGH +UP, reloading..."; }); # wait for event $done->recv; exit 0;
Running this code on Debian Squeeze (Perl 5.10) and sending a SIGHUP to the process via kill -HUP 12345 perl just quits with the message "Hangup" spooled to STDIN.
What am I doing wrong? I would expect to see my message "Got SIGHUP, reloading..." before the exit. But the message "Hangup" makes me feel like the signal was not handled by AnyEvent but directly by perl.
Any suggestions?
Thanks.
nutris
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Handle SIGHUP with AnyEvent
by moritz (Cardinal) on Aug 23, 2011 at 09:39 UTC | |
by nutris (Initiate) on Aug 23, 2011 at 10:29 UTC | |
|
Re: Handle SIGHUP with AnyEvent
by Anonymous Monk on Aug 23, 2011 at 09:40 UTC | |
|
Re: Handle SIGHUP with AnyEvent
by Neighbour (Friar) on Aug 24, 2011 at 06:50 UTC | |
by Anonymous Monk on Nov 26, 2014 at 00:40 UTC |