From 89738ec9ae9329186ad6739cef36534fd9d4186f Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Fri, 22 Dec 2017 14:46:25 +0000 Subject: [PATCH] fork : allow to clean without blocking git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4010 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- fork.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fork.php b/fork.php index 3d48089..50bc6c1 100644 --- a/fork.php +++ b/fork.php @@ -113,6 +113,18 @@ class fork } } + /** Clean the childs which are finished. Do not block the process + */ + public function cleanEndChild () + { + $stoppedPid = pcntl_wait ($status, WNOHANG); + while ($stoppedPid > 0) + { + unset ($this->pidList[$stoppedPid]); + $stoppedPid = pcntl_wait ($status, WNOHANG); + } + } + /** Stop (SIGTERM) a specific child. * If the $maxWait parameter is set, wait the dead of the child for $maxWait * seconds. If $maxWait is not set, do not wait the child, only send it the