in reply to Handle SIGHUP with AnyEvent

#!/usr/bin/perl use strict; use warnings; use AnyEvent; $|++; my $done = AnyEvent->condvar; # set up event handler my $w = AnyEvent->signal(signal => "HUP", cb => sub { print "Got SIGHU +P, reloading...\n"; }); # wait for event $done->recv; exit 0;

Works fine. Don't forget that stdout is buffered (which $|++ fixes.

Replies are listed 'Best First'.
Re^2: Handle SIGHUP with AnyEvent
by Anonymous Monk on Nov 26, 2014 at 00:40 UTC
    Doesn't work for me. Running your script as is, it exits with "Terminated: 15" when sending it a SIGHUP. I came across this thread when I couldn't catch SIGALRM using AnyEvent with the EV loop, and had to resort to using a plain old perl signal handler.