On Mon, Dec 08, 2003 at 06:48:17PM -0800, david wrote:
> eval{
>
> local $SIG{ALRM} = sub { die 'alarm' };
>
> $child = fork;
>
> die 'fork' unless(defined $child);
>
> if($child){
> #--
> #-- give child 5 seconds to complete
> #--
> alarm(5);
> wait;
> alarm(0);
> }else{
> system("sleep $ARGV[0]");
This doesn't work, because system forks itself:
Parent
`- child1 (opened by fork)
`- child2 (opend by system of child1)
And $child holds the pid of the child opened by fork. So I'm using
exec($prog, @args);
at this point, and everything works fine.
> exit;
> }
> };
Thank you for help.
Mik
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>