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/