I write a demon that periodically does some work and sleeps for a while before repeating it again. But he still has to respond to external influences (i.e. Request for completion) during sleep.
I managed to implement a wait timeout with an ALRM signal and termination with a TERM signal (sample):
But for God's sake I can’t understand why the sighandler is never called. I get the following output:
$ php sigsample.php Doing some work. ALRM SIGWI Doing some work. ALRM SIGWI Doing some work. TERM SIGWI
And at the same time, if I do not install this handler, the script dies due to an unprocessed signal.
Am I missing something? Why has my signal handler function never been called? Does pcntl_sigwaitinfo () work?
And are there any other means for using timeout and signal processing at the same time?
Kaero source share