note 103564 deleted from function.pcntl-alarm by danbrown
| From: | danbrown@php.net | Date: | Wed, 20 Apr 2011 16:13:20 +0000 |
| Subject: | note 103564 deleted from function.pcntl-alarm by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179008@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
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 of class
similar to this one:
<?php
class SleepWorkaroundForSIGALRM {
private $time;
function __construct($seconds) {
$this->time = time() + $seconds;
while ($this->time >= time()) {
sleep(1);
}
}
?>