From:             kementeus at gmail dot com
Operating system: Debian 3.1
PHP version:      5.2.0
PHP Bug Type:     PCNTL related
Bug description:  pcntl_signal not working

Description:
------------
pcntl_signal is not executing the code inside the function handling of the
signal. The code example is taken from the php manual in
http://www.php.net/manual/en/ref.pcntl.php and modified just to echo a
simple text

Reproduce code:
---------------
<?php
declare(ticks=1);

$pid = pcntl_fork();
if ($pid == -1) {
     die("could not fork"); 
} else if ($pid) {
     exit(); // we are the parent 
} else {
     // we are the child
}

if (!posix_setsid()) {
   die("could not detach from terminal");
}

while (1) {
   // do something interesting here
}

function sig_handler($signo) 
{
     switch ($signo) {
         case SIGTERM:
             // handle shutdown tasks
             echo "I need to execute\n";
             exit;
             break;
         case SIGHUP:
             // handle restart tasks
             break;
         default:
             // handle all other signals
     }

}

// setup signal handlers
pcntl_signal(SIGTERM, "sig_handler");
pcntl_signal(SIGHUP, "sig_handler");
?> 

Expected result:
----------------
When you send the signal SIGTERM with kill -15 PID the process should echo
the message "I need to execute" and then terminate.

Actual result:
--------------
The process terminate but doesn't echo or execute anything inside the
function handler.

-- 
Edit bug report at http://bugs.php.net/?id=39972&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=39972&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=39972&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=39972&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=39972&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=39972&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=39972&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=39972&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=39972&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=39972&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=39972&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=39972&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=39972&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=39972&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=39972&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=39972&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=39972&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=39972&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=39972&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=39972&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=39972&r=mysqlcfg

Reply via email to