#40264 [Opn->Csd]: problem pcntl sample code
| From: | didou@php.net | Date: | Sun, 28 Jan 2007 16:52:56 +0000 |
| Subject: | #40264 [Opn->Csd]: problem pcntl sample code | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969375068@lists.php.net to get a copy of this message | ||
ID: 40264
Updated by: didou@php.net
Reported By: cocoiti at comio dot info
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: all
PHP Version: Irrelevant
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2007-01-28 16:04:06] cocoiti at comio dot info
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 this bug report at http://bugs.php.net/?id=40264&edit=1