ID:               37635
 Updated by:       [EMAIL PROTECTED]
 Reported By:      aeolianmeson at blitzeclipse dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         PCNTL related
 Operating System: Fedora 5
 PHP Version:      5.1.4
 New Comment:

>A list of the correct number of elements exists, however 
>the actual values become something else when dumped at program
termination.
I guess var_dump()'s output would worth all these words..


Previous Comments:
------------------------------------------------------------------------

[2006-05-30 03:16:05] aeolianmeson at blitzeclipse dot com

Description:
------------
There is a problem with the type of the parameter sent to a
signal-handling function.

If everytime the signal-handler adds the signal to an array, all array
keys and values will become corrupted. The total number of array
elements will be correct, but the actual values will sporadically
become arrays, etc...

This happens whereever the signal parameter was used. If the parameter
is typecast to an integer, it works perfectly. This  happens when the
handler is both a function and a method.

Reproduce code:
---------------
<?php
print("pid= " . posix_getpid() . "\n");
declare(ticks=1);
$arrtemp = array();

function handler($nsig)
{
        global $arrtemp;
        $arrtemp[] = $nsig;
        print("Signal caught and registered.\n");
        var_dump($arrtemp);
}

pcntl_signal(SIGTERM, 'handler');
$n = 15;
while($n)
{
        sleep(1);
        $n--;
}
print("terminated.\n\n");
var_dump($arrtemp);
?>

Expected result:
----------------
As the process receives SIGTERMs from the commandline, the handler adds
each signal value to the global array. When the program terminates, the
list is dumped, and should contain a list containing the correct number
of integers depicting the signals that were sent. The keys are normal
indexes.

Actual result:
--------------
A list of the correct number of elements exists, however the actual
values become something else when dumped at program termination.


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


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

Reply via email to