note 49202 added to function.pcntl-signal
| From: | ieure@php.net | Date: | Thu, 20 Jan 2005 01:15:42 +0000 |
| Subject: | note 49202 added to function.pcntl-signal | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-83647@lists.php.net to get a copy of this message | ||
Some weird signal interactions going on here. I'm running PHP 4.3.9.
sleep() calls seem to be interrupted when any signal is received by the PHP script. But things get
weird when you sleep() inside a signal handler.
Ordinarily, signal handlers are non-reentrant. That is, if the signal handler is running, sending
another signal has no effect. However, sleep() seems to override PHP's signal handling. If you
sleep() inside a signal handler, the signal is received and the sleep() is interrupted.
This can be worked around like this:
function handler($signal)
{
// Ignore this signal
pcntl_signal($signal, SIG_IGN);
sleep(10);
// Reinstall signal handler
pcntl_signal($signal, __FUNCTION__);
}
I don't see any mention of this behavior in the documentation.
----
Manual Page -- http://www.php.net/manual/en/function.pcntl-signal.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49202
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49202&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49202&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49202&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49202&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49202&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49202&report=yes
Search -- http://master.php.net/manage/user-notes.php