hey, thanks for the reply. The "-|" was the right option for me. The reason is because I only need to get the first 4 lines of output of the external program. "-|" was perfect because I don't have to base the stopping on time but rather on the number of output lines. Another problem solved!!! Till next time!
--- On Wed, 5/27/09, Chas. Owens <chas.ow...@gmail.com> wrote: > From: Chas. Owens <chas.ow...@gmail.com> > Subject: Re: variables gets shared to child but resets back after exiting fork > To: "Michael Alipio" <daem0n...@yahoo.com> > Cc: "begginers perl.org" <beginners@perl.org> > Date: Wednesday, May 27, 2009, 7:45 PM > On Wed, May 27, 2009 at 07:24, > Michael Alipio <daem0n...@yahoo.com> > wrote: > > > > Sorry about the indention... must be the mail client > i'm using. > > I need to fork because the external program I want to > run inside the child runs infinitely. I want to have a timer > running in the parent and after that, kill the child. > Without forking, I have to do a pkill myprogname > > I'm reading the perlipc now.. nothing so far.. > snip > > > You don't need a fork for that, you need alarm[1] and block > eval[2]: > > eval { > local $SIG{ALRM} = sub { die "timeout\n" }; > alarm 3; #die after three seconds > #operation that needs to die if it is not > finished in three seconds; > alarm 0; #turn off the alarm clock > 1; #make the eval return true > } or { > #propagate the error unless it is the > timeout > die $@ unless $@ eq "alarm\n"; > }; > > > > 1. http://perldoc.perl.org/functions/alarm.html > 2. http://perldoc.perl.org/functions/eval.html > > -- > Chas. Owens > wonkden.net > The most important skill a programmer can have is the > ability to read. > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/