POSIX module sig handlers vs default

Discussion in 'Perl Misc' started by bob, Sep 11, 2003.

  1. bob

    bob Guest

    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
     
    bob, Sep 11, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. steffen staehle
    Replies:
    0
    Views:
    514
    steffen staehle
    Sep 7, 2004
  2. steffen staehle
    Replies:
    0
    Views:
    566
    steffen staehle
    Sep 7, 2004
  3. matchstick86

    sig : process vs. process(sig)

    matchstick86, Oct 12, 2009, in forum: VHDL
    Replies:
    1
    Views:
    579
    power_hf2005
    Oct 13, 2009
  4. Replies:
    7
    Views:
    110
    Michele Dondi
    Apr 9, 2004
  5. Anno Siegel

    localizing %SIG handlers

    Anno Siegel, Oct 11, 2004, in forum: Perl Misc
    Replies:
    12
    Views:
    201
    Ilya Zakharevich
    Oct 31, 2004
Loading...

Share This Page