Kill a forked child job immediately. The job it is processing will not
be completed.
554226
public function killChild()
    {
        if (!$this->child) {
            $this->logger->notice('No child to kill.');
            return;
        }

        $this->logger->notice('Killing child at {pid}', array('pid' => $this->child));

        $command = escapeshellcmd($this->options['ps']);

        foreach ($this->options['ps_args'] as $arg) {
            $command .= ' ' . escapeshellarg($arg);
        }

        if (exec('ps ' . $this->child, $output, $returnCode) && $returnCode != 1) {
            $this->logger->notice('Killing child at ' . $this->child);
            posix_kill($this->child, SIGKILL);
            $this->child = null;
        } else {
            $this->logger->notice('Child ' . $this->child . ' not found, restarting.');
            $this->shutdown();
        }
    }
413605
function kill(req, res) {
  if(!this._busy || !this.ps) return res.send(NotBusy);
  if(this._busy && this._written) return res.send(Unkillable);
  this.ps.removeAllListeners();
  this._busy = false;
  this._written = false;
  function onClose() {
    res.send(null, Constants.OK);
    // re-spawn for next execution
    //this.spawn();
  }
  this.ps.once('close', onClose.bind(this))
  process.kill(this.ps.pid, 'SIGQUIT');
  this.emit('kill');
}
137864
def kill(self):
        """"""
        if not self.is_dead():
            self.bundle_engine.warnline("{0} did not shut down cleanly, killing.".format(self.service.name))
            try:
                if hasattr(self.process, 'pid'):
                    for child in psutil.Process(self.process.pid).children(recursive=True):
                        os.kill(child.pid, signal.SIGKILL)
                    self.process.kill()
            except psutil.NoSuchProcess:
                pass
945252
async function kill(pid) {
  try {
    process.kill(pid, 'SIGTERM')
  } catch (err) {
    if (err.code !== 'ESRCH') throw err
  }
}
485128
def kill_mprocess(process):
    
    if process and proc_alive(process):
        process.terminate()
        process.communicate()
    return not proc_alive(process)
1331794
protected function handleWorkerExit()
    {
        $result = swoole_process::wait();

        if(!empty($this->_noRestartProcesses[$result['pid']])) {
            unset($this->_noRestartProcesses[$result['pid']]);
            return;
        }

        if($result['signal'] > 0) {
            if($this->restartPolicy & self::RESTART_ON_SIGNAL) {
                $this->forkOneWorker();
            }
        } else {
            if($result['code'] > 0) {
                $this->_errors[] = microtime(true);

                if($this->restartPolicy & self::RESTART_ON_ERROR && !$this->_disableRestartOnError) {
                    if($this->tooManyErrors()) {
                        //if exceed the maximum error frequency, stop forking new workers on error
                        $this->_disableRestartOnError = true;
                    } else {
                        $this->forkOneWorker();
                    }
                }
            } else {
                if($this->restartPolicy & self::RESTART_ON_EXIT) {
                    $this->forkOneWorker();
                }
            }
        }
    }
1212001
def killBatchJobs(self, jobIDs):
        """"""
        log.debug('Killing jobs: {}'.format(jobIDs))
        for jobID in jobIDs:
            if jobID in self.runningJobs:
                info = self.runningJobs[jobID]
                info.killIntended = True
                if info.popen != None:
                    os.kill(info.popen.pid, 9)
                else:
                    # No popen if running in forkless mode currently 
                    assert self.debugWorker
                    log.critical("Can't kill job: %s in debug mode" % jobID)
                while jobID in self.runningJobs:
                    pass
991316
def killJobs(self, jobsToKill):
        
        if len(jobsToKill) > 0:
            self.batchSystem.killBatchJobs(jobsToKill)
            for jobBatchSystemID in jobsToKill:
                self.processFinishedJob(jobBatchSystemID, 1)
175614
def kill(self):
        
        try:
            kill(int(self.get()), 9)
            
        # Failed to kill the process
        except Exception as e:
            self.die('Failed to kill process: {}'.format(str(e)))
            
        # Remove the stale PID file
        self.remove()
377098
protected function kill_maxtime_violators()
	{
		foreach ($this->forked_children as $pid => $pid_info)
		{
			if ($pid_info['status'] == self::STOPPED)
			{
				continue;
			}

			if ($this->child_max_run_time[$pid_info['bucket']] >= 0 && (time() - $pid_info['ctime']) > $this->child_max_run_time[$pid_info['bucket']])
			{
				$this->log('Force kill ' . $pid . ' has run too long', self::LOG_LEVEL_INFO);

				// notify app that child process timed out
				$this->invoke_callback($this->child_function_timeout{$pid_info['bucket']}, array($pid, $pid_info['identifier']), true);

				$this->safe_kill($pid, SIGKILL); // its probably stuck on something, kill it immediately.
				sleep(3); // give the child time to die

				// force signal handling
				$this->signal_handler_sigchild(SIGCHLD);
			}
		}
	}
249702
public void kill() {
    boolean killNow = false;
    synchronized(jobInitKillStatus) {
      jobInitKillStatus.killed = true;
      //if not in middle of init, terminate it now
      if(!jobInitKillStatus.initStarted || jobInitKillStatus.initDone) {
        //avoiding nested locking by setting flag
        killNow = true;
      }
    }
    if(killNow) {
      terminate(JobStatus.KILLED);
    }
  }
483541
public function halt()
    {
        if($this->getProcess()->getPid() == getmypid()) {
            $this->stop();
            $this->haltCurrentJob();
        }else{
            $this->getProcess()->kill(SIGINT);
        }
    }
425699
def _kill_process(self, pid, sig=signal.SIGKILL):
        """"""
        try:
            os.kill(pid, sig)
        except OSError as e:
            if e.errno == errno.ESRCH: # process itself returned and exited before killing
                logging.debug("Failure %s while killing process %s with signal %s: %s",
                              e.errno, pid, sig, e.strerror)
            else:
                logging.warning("Failure %s while killing process %s with signal %s: %s",
                                e.errno, pid, sig, e.strerror)
1168139
def stop(self):
        """"""

        if self.run is True and all([self.job, self.job.is_alive()]):
            print('Done.')
            self.job.terminate()
1242934
public void kill() {
    if (isComplete() || failed) {
      return;
    }
    this.failed = true;
    killed = true;
    this.execFinishTime = JobTracker.getClock().getTime();
    recomputeProgress();
  }
241821
def kill_child_processes() -> None:
    
    timeout_sec = 5
    for p in processes:
        try:
            p.wait(timeout_sec)
        except TimeoutExpired:
            # failed to close
            p.kill()
315126
public Job fork() {
    init();
    H2OCountedCompleter task = new H2OCountedCompleter() {
      @Override public void compute2() {
        try {
          try {
            // Exec always waits till the end of computation
            Job.this.exec();
            Job.this.remove();
          } catch (Throwable t) {
            if(!(t instanceof ExpectedExceptionForDebug))
              Log.err(t);
            Job.this.cancel(t);
          }
        } finally {
            tryComplete();
        }
      }
    };
    start(task);
    H2O.submitTask(task);
    return this;
  }