php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #46555 Return value incorrect
Submitted: 2008-11-12 14:31 UTC Modified: 2008-11-14 14:52 UTC
From: jeroen at securew2 dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Debian
Private report: No CVE-ID: None
 [2008-11-12 14:31 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-14 14:52 UTC] lbarnaud@php.net
This bug has been fixed in CVS.

Thank you for the report, and for helping us make PHP better.
 [2020-02-07 06:10 UTC] phpdocbot@php.net
Automatic comment on behalf of lbarnaud
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=44df83211c7b54c94f4f930550e67d0848f2fd45
Log: Fixed #46555 (sleep() return value)
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 09:00:02 2026 UTC