(PHP 5 >= 5.3.0)
pcntl_sigtimedwait — Waits for signals, with a timeout
The pcntl_sigtimedwait() function operates in exactly the same way as pcntl_sigwaitinfo() except that it takes two additional parameters, seconds and nanoseconds, which enable an upper bound to be placed on the time for which the script is suspended.
Array of signals to wait for.
The siginfo is set to an array containing informations about the signal. See pcntl_sigwaitinfo().
Timeout in seconds.
Timeout in nanoseconds.
On success, pcntl_sigtimedwait() returns a signal number.
In the case if pcntl_sigtimedwait() is unavailable (under Mac OS, under PHP < 5.3), you can pick up the workaround:
<?php
if (!function_exists('pcntl_sigtimedwait'))
{
function pcntl_sigtimedwait($signals,$siginfo,$sec,$nano)
{
pcntl_signal_dispatch();
if (time_nanosleep($sec,$nano) === TRUE) {return FALSE;}
pcntl_signal_dispatch();
return TRUE;
}
}
?>
Behaviour of this function differs from original one. This function returns true if a signal was retrieved and false if it was not retrieved. However, the timeout will be interrupted immediately when signal sent.