note 103565 added to function.pcntl-alarm
| From: | thessoro at gmail dot com | Date: | Wed, 20 Apr 2011 16:05:40 +0000 |
| Subject: | note 103565 added to function.pcntl-alarm | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179007@lists.php.net to get a copy of this message | ||
If your process uses SIGALRM and sleep() at the same time, the alarm set could make sleep() to
return prematurely.
To avoid this and ensure your process waits a number of seconds you could use a function or class
similar to this one:
<?php
class SleepWorkaroundForSIGALRM {
private $time;
function __construct($seconds) {
$this->time = time() + $seconds;
while ($this->time >= time()) {
sleep(1);
}
}
?>
----
Server IP: 80.64.47.13
Probable Submitter: 217.116.1.84
----
Manual Page -- http://www.php.net/manual/en/function.pcntl-alarm.php
Edit -- https://master.php.net/note/edit/103565
Del: integrated -- https://master.php.net/note/delete/103565/integrated
Del: useless -- https://master.php.net/note/delete/103565/useless
Del: bad code -- https://master.php.net/note/delete/103565/bad+code
Del: spam -- https://master.php.net/note/delete/103565/spam
Del: non-english -- https://master.php.net/note/delete/103565/non-english
Del: in docs -- https://master.php.net/note/delete/103565/in+docs
Del: other reasons-- https://master.php.net/note/delete/103565
Reject -- https://master.php.net/note/reject/103565
Search -- https://master.php.net/manage/user-notes.php