php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35244 pcntl_waitpid blocks signal handling
Submitted: 2005-11-16 17:00 UTC Modified: 2005-11-24 01:00 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: joe dot maldonado at gmail dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.0.5 OS: Linux kernel 2.4.25
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: joe dot maldonado at gmail dot com
New email:
PHP Version: OS:

 

 [2005-11-16 17:00 UTC] joe dot maldonado at gmail dot com
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-16 18:17 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-11-24 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 26 13:01:46 2024 UTC