in reply to Re^2: SIGHUP with Proc::Daemon
in thread SIGHUP with Proc::Daemon

Woot! Its zeromq stuff. My new test app:

#!/usr/bin/perl use common::sense; use ZeroMQ ':all'; use Data::Dumper; my $ctx = ZeroMQ::Context->new(); my $sock = $ctx->socket(ZMQ_PULL); $sock->setsockopt(ZMQ_HWM, 500); $sock->bind('tcp://*:5558'); $SIG{HUP} = sub { print "got hup\n"; }; while (1) { my $msg = $sock->recv(); print "got message\n"; print Dumper(\$msg); }

after I sighup it, I get:
got hup got message $VAR1 = \undef;


In real code, I call $msg->data() next which when $msg is undef I can see that killing the script.

Its kinda weird that SIGHUP makes $sock->recv() return, but at least I can code around that.

thanks again,

-Andy

Replies are listed 'Best First'.
Re^4: SIGHUP with Proc::Daemon
by Eliya (Vicar) on Mar 09, 2012 at 19:56 UTC
    Its kinda weird that SIGHUP makes $sock->recv() return

    Actually, in this particular case, it's a plus, because it gives you the opportunity to do the reloading of the config before restarting the recv.