POSIX module sig handlers vs default

B

bob

Hi,

I have been reading Interprocess Communication in the Camel book 3rd ed,
and doing a lot of experimenting with IO::Socket::INET in at least one
example I found it uses the POSIX module to create single handlers. Here
is one example I am using now that seems to work:

my $sigset = POSIX::SigSet->new();
my $action = POSIX::SigAction->new('sigHUP_handler',
$sigset,
&POSIX::SA_NODEFER);
my $action_alrm = POSIX::SigAction->new('sigALRM_handler',
$sigset,
&POSIX::SA_NODEFER);


POSIX::sigaction(&POSIX::SIGHUP, $action);
POSIX::sigaction(&POSIX::SIGALRM, $action_alrm);

sub sigHUP_handler {
print "got SIGHUP\n";
exec($SELF, @ARGV) or die "Couldn't restart: $!\n";
}
sub sigALRM_handler {
print "got ALARM timeout\n";

}


So my question is what is different, about this vs using the much more
simple looking example below?

$SIG{CHLD} = \&REAPER;

sub REAPER {
$SIG{CHLD} = \&REAPER; # loathe sysV
$waitedpid = wait;
logmsg "reaped $waitedpid" . ($? ? " with exit $?" : '');
}

I have made, as in Dr. Franenstiem made the below script, but I am not
sure if I should handle this child cleanup by this simpler looking way,
or the POSIX way. The other thing that worries me on this, is that the
simple method is from an example using Socket whereas I am using the
higherlevel IO::SOCKET. Does that matter? I mean a single is a single
right?


Thanks,

Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top