From: aeolianmeson at blitzeclipse dot com Operating system: Fedora 5 PHP version: 5.1.4 PHP Bug Type: PCNTL related Bug description: Signal parameter to handler is other-typed (non-integer)
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 bug report at http://bugs.php.net/?id=37635&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37635&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37635&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37635&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37635&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37635&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37635&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37635&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37635&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37635&r=support Expected behavior: http://bugs.php.net/fix.php?id=37635&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37635&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37635&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37635&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37635&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37635&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37635&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37635&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37635&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37635&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37635&r=mysqlcfg