Edit report at https://bugs.php.net/bug.php?id=62413&edit=1

 ID:                 62413
 User updated by:    merlyn dot tgz at gmail dot com
 Reported by:        merlyn dot tgz at gmail dot com
 Summary:            sleep() strange behavior on pcntl signal event
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            PCNTL related
 Operating System:   Ubuntu
 PHP Version:        5.3.14
 Block user comment: N
 Private report:     N

 New Comment:

not a bug. I had reread about sleep() ) It's normal behavior, and useful, yeah


Previous Comments:
------------------------------------------------------------------------
[2012-06-25 19:38:36] merlyn dot tgz at gmail dot com

Description:
------------
If we install any signal handler and send that signal to our script proccess 
while sleep() function is running script will immideatly continue running from 
next string after sleep() execution. For reproduce you need to open two 
consoles, in first of them execute the script

$ php test.php

in second - determine it's pid

$ ps ax|grep php test.php

and send signal to script proccess

$ kill -s SIGHUP 12990

In provided output example i had wait while first iteration of while loop run 
completely, and after that have sent four times SIGHUP signal from other 
terminal

Test script:
---------------
<?php
declare(ticks=1);
function echo_sig($sigNum)
{
        echo "caught sig: $sigNum\n";
}

pcntl_signal(SIGHUP, 'echo_sig');
$a = 0;

while ($a < 5) {
        $a++;
        $startTime = time();
        sleep(10);
        echo "slept " . (time() - $startTime) . " seconds\n";
}

Expected result:
----------------
slept 10 seconds
caught sig: 1
slept 10 seconds
caught sig: 1
slept 10 seconds
caught sig: 1
slept 10 seconds
caught sig: 1
slept 10 seconds


Actual result:
--------------
slept 10 seconds
caught sig: 1
slept 4 seconds
caught sig: 1
slept 2 seconds
caught sig: 1
slept 0 seconds
caught sig: 1
slept 8 seconds



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62413&edit=1

Reply via email to