/**
  * @param Process $process
  * @return null
  * @throws CommandsExecutionException
  */
 public static function tryTerminateProcess(Process $process)
 {
     try {
         $terminationResult = $process->terminate();
         if (!$terminationResult) {
             throw new CommandsExecutionException("Process termination for PID " . $process->getPid() . " wasn't success");
         }
     } catch (\Exception $e) {
         try {
             self::sendSig($process->getPid(), SIGKILL);
         } catch (\Exception $e) {
             throw new CommandsExecutionException("SIGKILL for PID " . $process->getPid() . " wasn't success");
         }
     }
     return null;
 }
示例#2
0
 public function tryTerminateProcess(Process $process)
 {
     try {
         $terminationResult = $process->terminate();
         if (!$terminationResult) {
             throw new ReactManagerException("Process termination for PID " . $process->getPid() . " wasn't success");
         }
     } catch (\Exception $e) {
         try {
             $this->logAndSendSigKill($process->getPid(), $e);
         } catch (\Exception $e) {
             $this->logger->warning("Parent process can't be sigKilled.");
         }
     }
     return null;
 }
示例#3
0
 /**
  * @return null
  * @throws \CommandsExecutor\Inventory\Exceptions\CommandsExecutionException
  */
 protected function stopReplyStack()
 {
     LinuxCommands::sendSigTermOrKill($this->commandsManager->getPidByPpid($this->replyStackProcess->getPid())->getPid());
     LinuxCommands::tryTerminateProcess($this->replyStackProcess);
     return null;
 }