PHP 8.5.0 Alpha 1 available for testing

Voting

: min(four, two)?
(Example: nine)

The Note You're Voting On

ieure at php dot net
20 years ago
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.

<< Back to user notes page

To Top