note 104677 added to function.pcntl-wexitstatus

From: Date: Thu, 30 Jun 2011 05:04:18 +0000
Subject: note 104677 added to function.pcntl-wexitstatus
Groups: php.notes 
Request: Send a blank email to php-notes+get-181085@lists.php.net to get a copy of this message
$pid = pcntl_fork(); if ($pid == -1) { die("could not fork"); } else if ($pid) { // we are the parent $myId = pcntl_waitpid(-1, $status, 0); $children_ret = pcntl_wexitstatus($status); echo "return code " . $children_ret; return 0; } else { // we are the child return 2; } output: return code 0 you should use exit not return like this $pid = pcntl_fork(); if ($pid == -1) { die("could not fork"); } else if ($pid) { // we are the parent $myId = pcntl_waitpid(-1, $status, 0); $children_ret = pcntl_wexitstatus($status); echo "return code " . $children_ret; return 0; } else { // we are the child exit(2); } output: return code 2 ---- Server IP: 222.73.207.145 Probable Submitter: 127.0.0.1 (proxied: 116.228.58.60) ---- Manual Page -- http://www.php.net/manual/en/function.pcntl-wexitstatus.php Edit -- https://master.php.net/note/edit/104677 Del: integrated -- https://master.php.net/note/delete/104677/integrated Del: useless -- https://master.php.net/note/delete/104677/useless Del: bad code -- https://master.php.net/note/delete/104677/bad+code Del: spam -- https://master.php.net/note/delete/104677/spam Del: non-english -- https://master.php.net/note/delete/104677/non-english Del: in docs -- https://master.php.net/note/delete/104677/in+docs Del: other reasons-- https://master.php.net/note/delete/104677 Reject -- https://master.php.net/note/reject/104677 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#181085) next »