Send SIGABRT to child processes to instruct them to stop
548340
def shutdown(self):
        """"""
        self.signal_children(signal.SIGABRT)

        # Wait a few iterations when trying to stop children before terminating
        waiting = 0
        while self.living_children:
            time.sleep(0.5)
            waiting += 1
            if waiting == self.MAX_SHUTDOWN_WAIT:
                self.signal_children(signal.SIGKILL)
                break
659377
def _killall(self, force=False):
        """"""
        for_termination = []

        for n, p in iteritems(self._processes):
            if 'returncode' not in p:
                for_termination.append(n)

        for n in for_termination:
            p = self._processes[n]
            signame = 'SIGKILL' if force else 'SIGTERM'
            self._system_print("sending %s to %s (pid %s)\n" %
                               (signame, n, p['pid']))
            if force:
                self._env.kill(p['pid'])
            else:
                self._env.terminate(p['pid'])
457222
function kill(p, sig) {
  if (isWin) {
    let command = 'taskkill.exe';
    let args = ['/t', '/pid', p.pid];
    if (sig === 'SIGKILL') {
      args.push('/f');
    }

    execa(command, args).then(result => {
      // Processes without windows can't be killed without /F, detect and force
      // kill them directly
      if (result.stderr.indexOf('can only be terminated forcefully') !== -1) {
        kill(p, 'SIGKILL');
      }
    }).catch(err => {
      log.error(err);
    });
  } else {
    p.kill(sig);
  }
}
1306975
def command_stop(self):
        '''
        
        '''
        if self.pidfile:
            if not os.path.exists(self.pidfile):
                sys.exit("Pidfile {!r} doesn't exist".format(self.pidfile))
            with open(self.pidfile) as pidfile:
                pid = int(pidfile.read())
            for sig in [signal.SIGINT, signal.SIGTERM, signal.SIGKILL]:
                try:
                    if terminate(pid, sig, 3):
                        os.remove(self.pidfile)
                        # NOTE: we are not performing sys.exit here,
                        # otherwise restart command will not work
                        return
                except OSError as exc:
                    if exc.errno != errno.ESRCH:
                        raise
                    elif sig == signal.SIGINT:
                        sys.exit('Not running')
        sys.exit('No pidfile provided')
98735
def set_stop_handler(self):
        
        signal.signal(signal.SIGTERM, self.graceful_stop)
        signal.signal(signal.SIGABRT, self.graceful_stop)
        signal.signal(signal.SIGINT, self.graceful_stop)
751148
def kill_processes(self):
        
        LOGGER.critical('Max shutdown exceeded, forcibly exiting')
        processes = self.active_processes(False)
        while processes:
            for proc in self.active_processes(False):
                if int(proc.pid) != int(os.getpid()):
                    LOGGER.warning('Killing %s (%s)', proc.name, proc.pid)
                    try:
                        os.kill(int(proc.pid), signal.SIGKILL)
                    except OSError:
                        pass
                else:
                    LOGGER.warning('Cowardly refusing kill self (%s, %s)',
                                   proc.pid, os.getpid())
            time.sleep(0.5)
            processes = self.active_processes(False)

        LOGGER.info('Killed all children')
        return self.set_state(self.STATE_STOPPED)
363611
public function stop()
    {
        if ($this->isBusy()) {
            posix_kill($this->workPid, \SIGKILL);
            $this->getWorkState(true);
        }
    }
1365106
def stop(self, sig=signal.SIGTERM):
        

        if self.pid is None:
            self.pid = self.read_pid()
        if self.pid is None:
            sp = BackgroundProcess.objects.filter(pk=1).first()
            if sp:
                self.pid = sp.pid
        if self.pid is None or self.pid == 0:
            logger.error("can't determine process id exiting.")
            return False
        if self.pid != getpid():
            # calling from outside the daemon instance
            logger.debug('send sigterm to daemon')
            try:
                kill(self.pid, sig)
                return True
            except OSError as e:
                if e.errno == errno.ESRCH:
                    return False
                else:
                    return False

        logger.debug('start termination of the daemon')
        BackgroundProcess.objects.filter(pk=self.process_id).update(
            last_update=now(),
            message='stopping..')

        timeout = time() + 60  # wait max 60 seconds
        self.kill_processes(signal.SIGTERM)
        while self.PROCESSES and time() < timeout:
            self.kill_processes(signal.SIGTERM)
            sleep(1)
        self.kill_processes(signal.SIGKILL)
        BackgroundProcess.objects.filter(pk=self.process_id).update(
            last_update=now(),
            message='stopped')
        logger.debug('termination of the daemon done')
        return True
1075551
def Kill(self):
    """"""
    try:
      if self.is_running:
        self.Detach()
      if self._Execute('__kill__') == '__kill_ack__':
        # acknowledged, let's give it some time to die in peace
        time.sleep(0.1)
    except (TimeoutError, ProxyError):
      logging.debug('Termination request not acknowledged, killing gdb.')
    if self.is_running:
      # death pill didn't seem to work. We don't want the inferior to get killed
      # the next time it hits a dangling breakpoint, so we send a SIGINT to gdb,
      # which makes it disable instruction breakpoints for the time being.
      os.kill(self._process.pid, signal.SIGINT)
      # Since SIGINT has higher priority (with signal number 2) than SIGTERM
      # (signal 15), SIGTERM cannot preempt the signal handler for SIGINT.
      self._process.terminate()
      self._process.wait()
    self._errfile_r.close()
    self._outfile_r.close()
161808
def kill_process(procname, scriptname):
    """"""

    # from http://stackoverflow.com/a/2940878
    import signal
    import subprocess

    p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
    out, err = p.communicate()

    for line in out.decode().splitlines():
        if procname in line and scriptname in line:
            pid = int(line.split()[1])
            info('Stopping %s %s %d' % (procname, scriptname, pid))
            os.kill(pid, signal.SIGKILL)
1080173
def block(self):
        

        self._nosig = True
        yield
        self._nosig = False
        if self._interrupted:
            raise SystemExit("Aborted...")
1296681
def stop_process(self, process, timeout=None):
        

        process["terminate"] = True
        if timeout is not None:
            process["terminate_at"] = time.time() + timeout
        process["subprocess"].send_signal(signal.SIGINT)
1344247
def shutdown!
      shutdown
      if term_child
        if fork_per_job?
          new_kill_child
        else
          # Raise TermException in the same process
          trap('TERM') do
            # ignore subsequent terms
          end
          raise TermException.new("SIGTERM")
        end
      else
        kill_child
      end
    end
930496
async def stop(self):
        
        # negate pid so that signals apply to process group
        pgid = -self.process.pid
        try:
            os.kill(pgid, signal.SIGTERM)
            await asyncio.sleep(1)
            os.kill(pgid, signal.SIGKILL)
        except (OSError, ProcessLookupError):
            return
48039
def halt(self, message, emitter, *args, **kwargs):
        ''''''
        self.process_event((FINISH, self, (), {}))
        global_event_queue.clear()
634397
def terminate(self, signal_chain=KILL_CHAIN, kill_wait=KILL_WAIT_SEC, purge=True):
    """"""
    alive = self.is_alive()
    if alive:
      logger.debug('terminating {}'.format(self._name))
      for signal_type in signal_chain:
        pid = self.pid
        try:
          logger.debug('sending signal {} to pid {}'.format(signal_type, pid))
          self._kill(signal_type)
        except OSError as e:
          logger.warning('caught OSError({e!s}) during attempt to kill -{signal} {pid}!'
                         .format(e=e, signal=signal_type, pid=pid))

        # Wait up to kill_wait seconds to terminate or move onto the next signal.
        try:
          if self._deadline_until(self.is_dead, 'daemon to exit', timeout=kill_wait):
            alive = False
            logger.debug('successfully terminated pid {}'.format(pid))
            break
        except self.Timeout:
          # Loop to the next kill signal on timeout.
          pass

    if alive:
      raise ProcessManager.NonResponsiveProcess('failed to kill pid {pid} with signals {chain}'
                                      .format(pid=self.pid, chain=signal_chain))

    if purge:
      self.purge_metadata(force=True)
1146129
def terminate(self, unique_id, configs=None):
    
    self._send_signal(unique_id, signal.SIGTERM, configs)