fork : allow to clean without blocking

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4010 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2017-12-22 14:46:25 +00:00
parent 2835eafd12
commit 89738ec9ae

View File

@@ -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. /** Stop (SIGTERM) a specific child.
* If the $maxWait parameter is set, wait the dead of the child for $maxWait * 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 * seconds. If $maxWait is not set, do not wait the child, only send it the