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

  • Thread starter steffen staehle
  • Start date
S

steffen staehle

Hi,

I'm writing a server process which spawns child processes via fork
This server process should keep track of the number of children stil
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 rea
('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 signa
handling, and I wonder if I can safely go back to using the (mor
convenient) %SIG hash and leaving the rest up to perl.

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

Two concerns:

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

And I would like to make sure that child processes do NOT send
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 tim
the signal handler is executed; and is SA_NOCLDSTOP used by default s
that the handler only gets called if the child is dead, not if i
stops?

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

Thanks,
Steffe


-
steffen staehl
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top