#46555 [NEW]: Return value incorrect

From: Date: Wed, 12 Nov 2008 14:31:18 +0000
Subject: #46555 [NEW]: Return value incorrect
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-1488@lists.php.net to get a copy of this message
From:             jeroen at securew2 dot com
Operating system: Debian
PHP version:      Irrelevant
PHP Bug Type:     Documentation problem
Bug description:  Return value incorrect

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 bug report at http://bugs.php.net/?id=46555&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        http://bugs.php.net/fix.php?id=46555&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        http://bugs.php.net/fix.php?id=46555&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        http://bugs.php.net/fix.php?id=46555&r=trysnapshot60
Fixed in CVS:                        http://bugs.php.net/fix.php?id=46555&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=46555&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=46555&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=46555&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=46555&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=46555&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=46555&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=46555&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=46555&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=46555&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=46555&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=46555&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=46555&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=46555&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=46555&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=46555&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=46555&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=46555&r=mysqlcfg



Thread (2 messages)

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