Raymond Wan wrote:
> 
> Thank you very much for your reply!  I've actually been stuck on this 
> for a while...but with little knowledge about forking processes, I was a 
> quite stuck.
> 
> John W. Krahn wrote:
>> perldoc -f times
> 
> Ah, didn't know about that.  I thought to get user time, you had to run 
> something (say, /usr/bin/time) from a parent shell...i.e., you can't 
> tell what is your own user time.  Thanks for this!
> 
>>> $SIG{CHLD} = 'IGNORE';
>> Your problem appears to be this line.  When you run:
>>
>> exec '/usr/bin/time --output=time.txt ls &'
> 
> Ah, I see.  I was following directions elsewhere 
> (http://perldoc.perl.org/perlfaq8.html#How-do-I-start-a-process-in-the-background%3f),
>  
> and its comments about Zombies.  I guess I wanted to "reap" the child 
> processes, but in doing so, lost track of the process that I want to 
> time?  (I'm not so sure about this statement...)
> 
> I gave what you suggested a try and it works, but I now have a Zombie 
> process.  They also suggest a "double fork" solution, which seems like 
> it will give the best of both worlds...no zombies and I should be able 
> to time it...  I'll try that now...thanks a lot -- it did help me 
> understand the code I had taken from the FAQ.

What do you need to accomplish that something as simple as the code below won't 
do?

Rob


use strict;
use warnings;

my $kid = fork;

if ($kid) {
  print "in parent whose kid is $kid\n";
}
elsif ($kid == 0) {
  print "In child\n";
  my ($usertime) = times;
  print "$usertime seconds\n";
}
else {
  die "Cannot fork: $!\n";
}

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to