private function terminateWorker($pid)
{
$op = [];
exec('ps x -o command -p ' . intval($pid) . ' | grep -v "ps x -o command|grep " | grep -i "' . $this->name . '"', $op);
if (isset($op[1])) {
$this->getLogger()->debug("Terminating child process PID:%d", $pid);
//Process is running. Terminate it.
posix_kill($pid, SIGTERM);
}
if (isset($this->pids[$pid])) {
unset($this->pids[$pid]);
}
}