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.
pcntl_sigtimedwait
(PHP 5 >= 5.3.0)
pcntl_sigtimedwait — タイムアウトつきでシグナルを待つ
説明
int pcntl_sigtimedwait
( array $set
[, array &$siginfo
[, int $seconds = 0
[, int $nanoseconds = 0
]]] )
pcntl_sigtimedwait() 関数の挙動は pcntl_sigwaitinfo() とほぼ同じですが、さらに 2 つのパラメータがあります。 seconds および nanoseconds がそれで、 スクリプトが待ち続ける時間の上限をここで設定することができます。
パラメータ
- set
-
待つシグナルの配列。
- siginfo
-
シグナルについての情報を含む配列が siginfo に設定されます。 pcntl_sigwaitinfo() を参照ください。
- seconds
-
タイムアウトの秒数。
- nanoseconds
-
タイムアウトのナノ秒数。
返り値
成功した場合に pcntl_sigtimedwait() はシグナル番号を返します。
pcntl_sigtimedwait
kak dot serpom dot po dot yaitsam at gmail dot com
27-Jul-2009 07:50
27-Jul-2009 07:50
