Dear Ben,

Thanks for the detailed reply to my query.

If my questions below can be answered by online docs, please feel free
to point me to them.  I read through the following docs before my
previous email.  But I am still mostly in the dark:

* "man -s 2" for fork(), wait(), waitpid() and kill()
* "perldoc -f" for fork(), wait(), waitpid() and kill()
* "perldoc perlipc"

> 1 until -1 == wait();
> 
> You'll need something more complex if you want to track the children's
> exit statuses (very useful for debugging).

That idiom is good to know.  But I *do* need to track exit statuses
(stati?).  Please see my pseudo-code below.

> If you [use POSIX] you can
> 
>   $kid = waitpid(-1, WNOHANG);
> 
> to poll to see if a kid needs to be reaped. [...]

I've seen this verb "reap" in this context, but don't know what it
means.  When and how do I "reap" a kid?  How is "reaping" different
from kill()ing it?

> Rather than worry about whether you are a child/parent for the rest of
> your code, I usually put an exit() here.  [...]

Sorry, I don't follow at all.

> Explicitly managing children and forking tends to be a lot of work.
> Unless you really need the complexity, I find that it tends to be
> easier to take the "poor man's" approach and do system calls and open
> up pipes.

I'd much rather do system calls, if I can figure out how to wait for
the children to finish up.

All I really want is:

    system("something $_ &") for 1..5;
    &wait_for_all_children; # "1 until -1 == wait;" might suffice.
    &compute_summary_of_children_activities;

But that won't really work, will it?  system("something $_ &") will
launch "something" as a background job, and then come back in a flash
to tell me that I don't have any child.  So &wait_for_all_children
won't have anything at all to wait for.

peace,                  || No Coke at University of Michigan:
--{kr.pA}               || http://tinyurl.com/cbdal
-- 
How do you spell "unwritten rule"?
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to