#46555 [Opn->Csd]: Return value incorrect

From: Date: Fri, 14 Nov 2008 14:52:34 +0000
Subject: #46555 [Opn->Csd]: Return value incorrect
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-1502@lists.php.net to get a copy of this message
 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)

« previous php.doc.bugs (#1502) next »