On Fri, 24 Sep 2004 11:52:19 -0400, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> I am a beginner, but I love to see all the knowledge transfer so keep the
> moderate to difficult questions coming!
>
<<SNIP>>
I'm like you, Derek! I love just reading this stuff. Satisfies some
inner-geek need I have!
>
> On Fri, 24 Sep 2004 10:34:50 -0500, Errin Larsen <[EMAIL PROTECTED]>
> wrote:
> > On Fri, 24 Sep 2004 17:20:44 +0200, Jenda Krynicky <[EMAIL PROTECTED]>
> wrote:
> > > From: Errin Larsen <[EMAIL PROTECTED]>
>
> <<SNIP>>
>
<<SNIP>>
> This seems to do something similar to what I want, but I'm confused
> about exactly what it's doing. what does the '-1' argument to
> waitpid() do? What is the 'WNOHANG' flag? Why are we reassigning
> '$SIG{CHLD}' to 'REAPER' inside of REAPER (this seems redundant to
> me!)
>
<<SNIP>>
Ok, I found this is the Perl Cookbook. Below is a quote:
" To avoid accumulating dead children, simply tell the system that
you're not interested in them by setting $SIG{CHLD} to "IGNORE". If
you want to know which children die and when, you'll need to use
waitpid.
The waitpid function reaps a single process. Its first argument is the
process to wait for - use -1 to mean any process - and its second
argument is a set of flags. We use the WNOHANG flag to make waitpid
immediately return 0 if there are no dead children. A flag value of 0
is supported everywhere, indicating a blocking wait. Call waitpid from
a SIGCHLD handler, as we do in the Solution, to reap the children as
soon as they die.
The wait function also reaps children, but it does not have a
non-blocking option. If you inadvertently call it when there are
running child processes but none have exited, your program will pause
until there is a dead child. "
Now, why can't the {perldoc -f waitpid} tell me "use -1 to mean any
process" ?!? That would have been helpful!!
--Errin
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>