> On Feb 18, 2004, at 3:50 PM, Papo Napolitano wrote:
>
> > Hi!
> >
> > I'm using the "select undef, undef, undef, 60" trick to sleep for 60
> > seconds.
> > But it seems to not work after I do a couple of forks like this:
> >
> > while (1) {
> >   Fork('sub1');
> >   Fork('sub2');
> >   Fork('sub3');
> >   select undef, undef, undef, 60;
> > }
> >
> > "Fork" just fork and run the supplied sub in the new child, returning
> > to the
> > parent.
> > Any clue as to what could be causing this behaviour?
>
> I'm thinking about this some more and I had another idea.  Maybe one of
> the guys who's more familiar with fork()ing can confirm this for us,
> but I suspect the child signal is interrupting your sleep.
>
> Do you have a signal handler installed?


I only have this:

$SIG{'CHLD'} = sub { wait };
$SIG{'INT'}  = sub { $running = 0 };
$SIG{'TSTP'} = sub { $running = 0 };
$SIG{'QUIT'} = sub { $running = 0 };
$SIG{'TERM'} = sub { $running = 0 };

The fork loop will run as long $running == 1 and the wait in the CHLD
handler is to prevent zombies...


>
> The only solution I can think of, if that's the case, is to add another
> sleep to the signal handler.  I believe that would work.  Of course,
> you might need to track the times yourself, and adjust the length of
> the second call based on elapsed sleep if staying close to 60 seconds
> is important.
>
> Again, hopefully one of the fork() gurus will confirm this for us...
>
> James


I could also try a double-fork, but tomorrow... Right now I'm tired, time to
go home.

Thanks!!


-- 
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