> -----Original Message-----
> From: Maxim Goncharov [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, October 27, 2001 1:30 PM
> To: [EMAIL PROTECTED]
> Subject: please help with fork
> 
> 
>  HI everyone,
> 
>  I need help with understanding what is happening when I fork a
> process.Here is actual code:
> 
> #!/usr/bin/perl -w
> use strict;
> use Fcntl qw(:DEFAULT :flock);
> use POSIX;
> #use Mail::Mailer;
> my ($pid);
> $pid = open(HHH,"| infloop");
> if($pid){
>     print HHH "bla bla \n";
> }
> 
> where infloop is another perl program that just sits in the infinite
> loop. Program as written is doing what it supposed: parent 
> spawns another
> process, prints stuff into it, and exits (because I do not 
> close(HHH)).

It would exit whether or not you closed HHH.

> However, if I uncomment line Mail::Mailer, the parent all of a sudden
> would sit and wait for the child to exit, as if I called 
> close(HHH). Would
> anyone please explain it to me.

Your example code as posted behaves identically for me whether Mail::Mailer
is use'd or not. I have set up infloop as:

   while (<>) { }

In both cases, the parent and child terminate. The parent does not "hang".


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

Reply via email to