From: joe dot maldonado at gmail dot com Operating system: Linux kernel 2.4.25 PHP version: 5.0.5 PHP Bug Type: Scripting Engine problem Bug description: pcntl_waitpid blocks signal handling
Description: ------------ Ran a test script using pcntl_waitpid (below) to see if it could be interrupted via a signal. The result was that the child process was not terminated upon sending the parent a signal. Reproduce code: --------------- #!/usr/local/bin/php -c/usr/local/lib/php.ini <?php declare(ticks = 1); $child_pid = 0; function sig_handler($signo) { global $child_pid; echo "got signal {$signo}\n"; echo "Child pid = $child_pid\n"; if ($child_pid != 0) { posix_kill($child_pid, SIGTERM); } exit(0); } if (!pcntl_signal(SIGTERM, "sig_handler", true)) echo "did not install sigterm\n"; function run_child() { global $child_pid; $child_pid = pcntl_fork(); if ($child_pid == -1) { echo "fork failed\n"; } else if ($child_pid > 0) { echo "parent = " . getmypid() . "\n"; echo "child = {$child_pid}\n"; echo "waiting...\n"; pcntl_waitpid($child_pid, $status); } else { $cmd = "/root/sigchild.sh"; exec($cmd); echo "could not exec child"; } } run_child(); ?> contents of sigchild.sh !/bin/sh sleep 100; echo "done sleeping" Expected result: ---------------- When a SIGTERM is sent to the parent process it should be handled by the signal handler and pass the signal to the child process, then exit. Actual result: -------------- when a SIGTERM is sent to the parent process it is not currently being handled, instead the child will continue to sleep and exit normally. -- Edit bug report at http://bugs.php.net/?id=35244&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=35244&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=35244&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=35244&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=35244&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=35244&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=35244&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=35244&r=needscript Try newer version: http://bugs.php.net/fix.php?id=35244&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=35244&r=support Expected behavior: http://bugs.php.net/fix.php?id=35244&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=35244&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=35244&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=35244&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35244&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=35244&r=dst IIS Stability: http://bugs.php.net/fix.php?id=35244&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=35244&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=35244&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=35244&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=35244&r=mysqlcfg