Re: signal handlers: does %SIG{'CLD'} require explicit SA_NOCLDSTOP via POSIX funcs?

Discussion in 'Perl' started by steffen staehle, Sep 7, 2004.

  1. Hi,

    I'm writing a server process which spawns child processes via fork.
    This server process should keep track of the number of children still
    running, do the necessary cleanup to avoid zombies, etc.

    In the beginning I thought I had to use the POSIX module, using SigSet,
    SigAction, sigprocmask etc. for a rather paranoid approach.

    Then I've read
    ('http://cis.uniroma2.it/guides/perl/pod/perlipc/deferred_signals__safe_signals_.html'
    (http://)) that as of perl 5.7.3, perl is safe(r) concerning signal
    handling, and I wonder if I can safely go back to using the (more
    convenient) %SIG hash and leaving the rest up to perl.

    My major concern is to keep track of the child processes (maintain PIDs
    of living children in a hash, wait for dead children, remove their PIDs
    from the hash). Which I probably could conveniently do with a signal
    handler for the SIGCHLD (or is it SIGCLD?) signal.

    Two concerns:

    I would like to make sure to defer any further signal handling while
    the signal handler itself is active.

    And I would like to make sure that child processes do NOT send a
    SIGCHLD on stop, which I think can be set via something like


    Code:
    --------------------
    POSIX::SigAction->new( 'main::catch_sigchld', $sigset_chld, &POSIX::SA_NOCLDSTOP)
    --------------------


    Now my question:

    Do the later perl versions automatically defer signals during the time
    the signal handler is executed; and is SA_NOCLDSTOP used by default so
    that the handler only gets called if the child is dead, not if it
    stops?

    In other words, can I rely upon %SIG to install my handlers, or should
    I use the POSIX module objects/functions?

    Thanks,
    Steffen



    --
    steffen staehle
    ------------------------------------------------------------------------
    Posted via http://www.codecomments.com
    ------------------------------------------------------------------------
     
    steffen staehle, Sep 7, 2004
    #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:
    499
    steffen staehle
    Sep 7, 2004
  2. Michael Pronath
    Replies:
    1
    Views:
    1,194
    Diez B. Roggisch
    Jan 3, 2005
  3. matchstick86

    sig : process vs. process(sig)

    matchstick86, Oct 12, 2009, in forum: VHDL
    Replies:
    1
    Views:
    571
    power_hf2005
    Oct 13, 2009
  4. bob
    Replies:
    0
    Views:
    97
  5. Replies:
    7
    Views:
    102
    Michele Dondi
    Apr 9, 2004
Loading...

Share This Page