Hi,

the subject is admittedly not very enlighening ... ;-;
what I am trying to do is:

- run a little program, that just sleeps for a given time
- when it receives a signal, restarts sleeping again for the
  full time period until it receives another signal or the
  timer elapses. In the latter case it should just exit.
  Something like:

sub sleeper {
    warn strftime("%H:%M:%S sleep $sleeptime\n", localtime);
    $SIG{USR1}=\&sleeper;
    sleep $sleeptime;
};

warn $$;
sleeper;

It sounds very simple, but I can't get it to work as intended.
I tryied it in numberless variations using sleep, Time::HiRes,
alaram/pause ... the actual result is always pretty much the same:

- When the program receives the 1st USR1 signal, it is interrupted
  immediately and "sleeper" is called. The pending alarm is obviously
  canceled and restarted as intended
- Any subsequent USR1 signal is only reacted to when the full $sleeptime
  starting from the previous signal is elapsed. If more than 1 signal is
  received in the meantime, additional signals are lost.

Does anybody have an idea why this doesn't work and how to get the
intendeded result? Any suggestions are appreciated ...
(This is taking place on a Linux 2.6.32 kernel using perl 5.10.0 ...)

Regards,
                         Peter


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to