From:             cocoiti at comio dot info
Operating system: all
PHP version:      Irrelevant
PHP Bug Type:     Documentation problem
Bug description:  problem pcntl sample code

Description:
------------
There is a problem in the sample code of this URL. 

http://www.php.net/manual/en/ref.pcntl.php

Pcntl_signal is not executed because there is "while". 

Please change as follows. 



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
}

// detatch from the controlling terminal
if (!posix_setsid()) {
   die("could not detach from terminal");
}


function sig_handler($signo)
{

     switch ($signo) {
         case SIGTERM:
             // handle shutdown tasks
             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");

// loop forever performing tasks
while (1) {

   // do something interesting here

}

?> 


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

Reply via email to