> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 30, 2002 5:48 PM
> To: Perl Discuss
> Subject: forking wrecks havoc with print statements
> 
> 
> hello all, i'm having some issues with subroutines being ran 
> on a forked 
> process. the subroutines have print statements which i would 
> like to have 
> printed to stdout in a format similar to:
> 
> "\nthis is my message\n\n"
> 
> however, the print format is not as controlled as it is when i do not 
> fork. sometimes my command line is returned before the final print 
> statement in the loop. i'll see my first three prints, and 
> then my command 
> line prompt, with the fourth print statement appearing after 
> the prompt.
> 
> do i need a wait() statement? and if so, where? i'm not too 
> familiar with 
> the function. thanks -c

The prompt appears when the parent finishes, even if the children haven't
finished yet.

If you want the parent to wait for all the children to finish, you can
add a statement like the following at the end of your main program:

   1 while wait != -1;

wait() returns -1 when there are no more children.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to