SPUG:Child Processes
Brian Hatch
spug at ifokr.org
Tue Feb 18 10:04:48 CST 2003
> I am trying to make the parent wait until all the children finish,
> but other then the brute force method of looping thru watching the
> processes in the process list while looking for a key phrase I have
> not been able to make the parent wait for all the children to finish.
while ( wait() != -1 ) {
# do nothing
}
wait() will block until a child finishes. When there are no more
children, it returns -1.
If you've set up a SIGCHLD handler to automatically reap them, this
may not work.
> In Korn shell you can put in a wait statement after releasing the
> children and all is well, but perl does not seem to have a simple
> equivilent.
wait and waitpid are really all you need. Both block (waitpid blocks
unless you use WNOHANG) so you're not going to sit in a busy wait.
--
Brian Hatch Bri: "Do you want to go
Systems and get a steamed milk?"
Security Engineer Reegen: "No. Caffene."
http://www.ifokr.org/bri/
Every message PGP signed
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/spug-list/attachments/20030218/025556e6/attachment.bin
More information about the spug-list
mailing list