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
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