note 103565 deleted from function.pcntl-alarm by googleguy

From: Date: Tue, 22 Oct 2013 12:16:19 +0000
Subject: note 103565 deleted from function.pcntl-alarm by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197123@lists.php.net to get a copy of this message
Note Submitter: thessoro at gmail dot com ---- 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); } } ?>

« previous php.notes (#197123) next »