mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-15 03:12:40 +01:00
21 lines
377 B
PHP
21 lines
377 B
PHP
|
<?php
|
||
|
|
||
|
if ($argc != 2) {
|
||
|
echo "usage: sleep <duration>\n";
|
||
|
exit(1);
|
||
|
}
|
||
|
|
||
|
// NOTE: Sleep for the requested duration even if our actual sleep() call is
|
||
|
// interrupted by a signal.
|
||
|
|
||
|
$then = microtime(true) + (double)$argv[1];
|
||
|
while (true) {
|
||
|
$now = microtime(true);
|
||
|
if ($now >= $then) {
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
$sleep = max(1, ($then - $now));
|
||
|
usleep((int)($sleep * 1000000));
|
||
|
}
|