> On Feb 18, 2004, at 4:45 PM, Papo Napolitano wrote:
> 
> > Heh, sorry... I simplified the code...
> > I'm still not posting the full source because it's like 15 files :(
> >
> >
> > while (1) {
> >   Fork("Whatever");
> >   sleep 60;
> > }
> 
> The first time you showed this loop, it had multiple fork()s in it.  
> Now it's just one.  Which is it.
> 
> > sub Fork {
> >   my $module = shift;
> >   my @params = @_;
> >   my $pid = fork;
> >   return $pid if $pid;
> >   $module->Run(@params);
> >   exit;
> > }
> 
> This routine looks okay to my eyes.  How long does a call to Run() 
> generally take?  Is it really just the one call to print you show?

Yeah

> 
> [snip]
> 
> > Uhmmm, sleep isn't working neither...
> 
> Define "isn't working" for us.  How do you know it's not sleeping for 
> 60 seconds?


I'm changing the code to try to make it work... Right now I'm using:

for ('test1', 'test2', 'test3') {
  print STDERR scalar(localtime) . " - fork $_\n";
  Fork("TestModule", $_);
  print STDERR scalar(localtime) . " - enter sleep\n";
  sleep 60;
  print STDERR scalar(localtime) . " - exit sleep\n";
}

And in TestModule.pm:

package TestModule;
sub Run {
  my $self = shift;
  my $param = shift;
  print STDERR scalar(localtime) . " - $self: $param\n";
}

Output is this:

Wed Feb 18 20:37:04 2004 - fork test1
Wed Feb 18 20:37:04 2004 - enter sleep
Wed Feb 18 20:37:04 2004 - TestModule: test1
Wed Feb 18 20:37:04 2004 - exit sleep
Wed Feb 18 20:37:04 2004 - fork test2
Wed Feb 18 20:37:04 2004 - enter sleep
Wed Feb 18 20:37:04 2004 - TestModule: test2
Wed Feb 18 20:37:04 2004 - exit sleep
Wed Feb 18 20:37:04 2004 - fork test3
Wed Feb 18 20:37:04 2004 - enter sleep
Wed Feb 18 20:37:04 2004 - TestModule: test3
Wed Feb 18 20:37:04 2004 - exit sleep
Wed Feb 18 20:37:04 2004 - fork test1
Wed Feb 18 20:37:04 2004 - enter sleep
Wed Feb 18 20:37:04 2004 - TestModule: test1
Wed Feb 18 20:37:04 2004 - exit sleep
Wed Feb 18 20:37:04 2004 - fork test2
Wed Feb 18 20:37:04 2004 - enter sleep
Wed Feb 18 20:37:04 2004 - TestModule: test2
Wed Feb 18 20:37:04 2004 - exit sleep
Wed Feb 18 20:37:04 2004 - fork test3
Wed Feb 18 20:37:04 2004 - enter sleep
Wed Feb 18 20:37:04 2004 - TestModule: test3
Wed Feb 18 20:37:04 2004 - exit sleep

And so on...
I bet you it isn't sleeping a single nanosec ;)


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


Reply via email to