note 123755 added to function.pcntl-waitpid
| From: | renmengyang567 at gmail dot com | Date: | Sun, 07 Apr 2019 18:26:50 +0000 |
| Subject: | note 123755 added to function.pcntl-waitpid | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-210542@lists.php.net to get a copy of this message | ||
<?php
declare(ticks = 1);
function zp_handler($signal) {
$id = pcntl_waitpid(-1, $status, WNOHANG);
if (pcntl_wifexited($status))
{
printf("Removed Chlid id: %d \n",$id);
printf("Chlid status: %d \n",pcntl_wexitstatus($status));
}
}
//pcntl_signal_dispatch();
pcntl_signal(SIGCHLD, "zp_handler");
//pcntl_signal_dispatch();
//
$pid = pcntl_fork();
if ($pid == 0)
{
print "#1 Hi, I'm child process".PHP_EOL;
sleep(3);
return 10;
}
else
{
print "#1parent process id:".$pid.PHP_EOL;
$pid = pcntl_fork();
if ($pid == 0)
{ print "#2 Hi, I'm child process".PHP_EOL;
sleep(10);
exit(20);
}
else
{
print "#2parent process id:".$pid.PHP_EOL;
for ($i=0; $i <10 ; $i++) {
print "wait..".PHP_EOL;
sleep(10);
}
}
}
?>
----
Server IP: 208.43.231.9
Probable Submitter: 185.85.3.142 (proxied: 104.199.167.217)
----
Manual Page -- http://php.net/manual/en/function.pcntl-waitpid.php
Edit -- https://master.php.net/note/edit/123755
Del: integrated -- https://master.php.net/note/delete/123755/integrated
Del: useless -- https://master.php.net/note/delete/123755/useless
Del: bad code -- https://master.php.net/note/delete/123755/bad+code
Del: spam -- https://master.php.net/note/delete/123755/spam
Del: non-english -- https://master.php.net/note/delete/123755/non-english
Del: in docs -- https://master.php.net/note/delete/123755/in+docs
Del: other reasons-- https://master.php.net/note/delete/123755
Reject -- https://master.php.net/note/reject/123755
Search -- https://master.php.net/manage/user-notes.php