/** * @return null|int */ public function getId() { if ($this->task instanceof Process) { return $this->task->getId(); } return null; }
/** * Revoke any background processes attached to this task. * * @param Task $task * * @return bool */ private function killTask(Task $task) { if ($task instanceof Process) { $stdout = $this->getStdOut(); $stderr = $this->getStdErr(); $this->getShell()->exec("kill -9 %s {$stdout} {$stderr} &", [$task->getId()]); return true; } return false; }
/** * Revoke any background processes attached to this task. * * @param Task $task * * @return bool */ private function killTask(Task $task) { if ($task instanceof Process) { $this->getShell()->exec("kill -9 %s", [$task->getId()]); return true; } return false; }
/** * Checks whether a running process can be removed (has stopped running). * * @param Task $task * * @return bool */ protected function canRemoveTask(Task $task) { if (!$task instanceof Process) { return true; } $processes = array_filter($this->running, function (Task $task) { return $task instanceof Process; }); if (count($processes) < 1) { return true; } $found = false; $stats = $this->getStatsForProcesses($processes); foreach ($stats as $stat) { if ($stat[0] === $task->getId()) { $found = true; } } return !$found; }
/** * Revoke any background processes attached to this task * * @param Task $task * @return bool If the process was killed */ protected function killTask(Task $task) { if ($task instanceof Process) { $this->getShell()->exec("kill -9 %s", array($task->getId())); return true; } return false; }