#46555 [Opn->Csd]: Return value incorrect
ID: 46555
Updated by: lbarnaud@php.net
Reported By: jeroen at securew2 dot com
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: Debian
PHP Version: Irrelevant
New Comment:
This bug has been fixed in CVS.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2008-11-12 14:31:17] jeroen at securew2 dot com
Description:
------------
The return values specified on the top of the page are not correct.
At least, not in php 5.2.0
Sleep returns the amount of seconds left when the function exits.
Signals for instance, can break a sleep. In that case sleep will return
the amount of seconds he didn't get to 'sleep'.
Reproduce code:
---------------
function alarm_handler() {
print "Caught SIGALRM\n";
pcntl_alarm(1);
}
function term_handler() {
print "Caught SIGTERM\n";
}
function int_handler() {
print "Ctrl+C will not help this time, m8!\n";
}
pcntl_signal(SIGALRM, "alarm_handler", true);
pcntl_signal(SIGTERM, "term_handler", true);
pcntl_signal(SIGINTM, "int_handler", true);
pcntl_alarm(1);
for(;;) {
print sleep(30)." seconds left.\n";
print "reloop and sleeping again.\n";
}
Expected result:
----------------
Since the sleep is broken, i'd expect a FALSE as documented
Actual result:
--------------
however, it returns the amount of seconds remaining before the actual
sleep would be over.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46555&edit=1
Thread (2 messages)