|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-11-16 18:17 UTC] sniper@php.net
[2005-11-24 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 14:00:02 2025 UTC |
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.