Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > POSIX module sig handlers vs default

Reply
Thread Tools

POSIX module sig handlers vs default

 
 
bob
Guest
Posts: n/a
 
      09-11-2003
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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sig : process vs. process(sig) matchstick86 VHDL 1 10-13-2009 01:07 AM
signal handlers: does %SIG{'CLD'} require explicit SA_NOCLDSTOP via POSIX funcs? steffen staehle Perl 0 09-07-2004 03:22 PM
Re: signal handlers: does %SIG{'CLD'} require explicit SA_NOCLDSTOP via POSIX funcs? steffen staehle Perl 0 09-07-2004 03:22 PM
scoping, sig handlers, and labels ctcgag@hotmail.com Perl Misc 7 04-09-2004 07:00 AM



Advertisments