> -----Original Message----- > From: Sudarshan Raghavan [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 14, 2002 7:49 AM > To: Perl beginners > Subject: Re: How does ZOMBIE/defunct affect the system? > > > On Tue, 13 Aug 2002, Ahmed Moustafa wrote: > > > Ahmed Moustafa wrote: > > > Drieux wrote: > > > > > >> > > >> > > >> use POSIX ":sys_wait_h"; > > >> #... > > >> do { > > >> $kid = waitpid(-1,&WNOHANG); > > >> } until $kid == -1; > > > > > > > > > Does the execution of the program wait to all the forked > processes to > > > terminate? > > > > Perl Cookbook says "We use the WNOHANG flag to make waitpid > immediately > > return 0 if there are no dead children". > > Yes WNOHANG makes waitpid return immediately the -1 means wait for any > child process. This code will do a non-blocking wait for all child > processes. > > > > > So, the above code doesn't pause the program, does it? > > It will be in the do-until loop until all of it's children are dead. > perldoc -f waitpid
This example is straight out of perldoc -f waitpid, but if it's used "as-is", I don't see the point. Why do a non-blocking wait, when the do loop effectively blocks the program anyway. You only want non-blocking when you have something else to do. I would write the above as: 1 while wait != -1; # wait for all children Or am I missing something? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]