Kill

 @param [String] remove_pid_file Remove the daemon pid file
549283
def kill(remove_pid_file=true)
      if running?
        log(:info, "Killing \"#{@name}\" (PID: #{@pid})")
        execute_callback(:kill)
        Process.kill 9, @pid
      end

      FileUtils.rm(@pid_file) if remove_pid_file
    rescue Errno::ENOENT
    end
827812
def exit(self):
        
        self.logger.warning("Stopping daemon.")
        os.remove(self.pid)
        sys.exit(0)
657698
def stop
    return self unless running?
    if @pid
      begin
        ::Process.kill 'TERM', @pid
        ::Process.wait @pid
      rescue SystemCallError
        # Process died on its own.
      ensure
        @pid = nil
      end
    end

    FileUtils.rm_rf @data_dir if File.exist?(@data_dir)
    @running = false
    self
  end
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)
662258
def _kill_process(self, box_config):
        
        try:
            self.logger.info('kill: {0} {{'.format(box_config.process_name))
            self.logger.info('target process pid={0}'.format(box_config.pid))
            if box_config.pid and psutil.pid_exists(box_config.pid):
                p = psutil.Process(box_config.pid)
                p.kill()
                p.wait()
                box_config.pid = None
                self.bc_dao.update(box_config)
                remove_pid_file(box_config.process_name)
        except Exception:
            self.logger.error('Exception on killing: {0}'.format(box_config.process_name), exc_info=True)
        finally:
            self.logger.info('}')
754769
def kill(self):
        
        try:
            os.unlink(self.server_address)
        except OSError:
            if os.path.exists(self.server_address):
                raise
1075319
def kill(*services, signal: 'KILL')
      o = opts(signal: [signal, 'KILL'])
      run!('kill', o, services)
    end
356554
def kill(self, dwExitCode = 0):
        
        hProcess = self.get_handle(win32.PROCESS_TERMINATE)
        win32.TerminateProcess(hProcess, dwExitCode)
407057
def delete(id)
      unless Debugger.started? && Debugger.remove_breakpoint(id)
        raise ArgumentError, "No breakpoint ##{id}"
      end
      Pry.processor.debugging = false if to_a.empty?
    end
377306
def kill
      mutex.synchronize do
        break if shutdown?
        stop_event.set
        kill_execution
        stopped_event.set
      end
      true
    end
1224025
def kill_process_children(pid):
    
    if sys.platform == "darwin":
        kill_process_children_osx(pid)
    elif sys.platform == "linux":
        kill_process_children_unix(pid)
    else:
        pass
408868
def kill_pid(self, pid):
        
        try:

            p = psutil.Process(pid)

            p.terminate()

            self.info_log('Killed [pid:%s][name:%s]' % (p.pid, p.name()))
        except psutil.NoSuchProcess:
            self.error_log('No such process: [pid:%s]' % pid)
445915
def daemon_running?
      return false unless File.exist?(options[:pid_path])
      Process.kill 0, File.read(options[:pid_path]).to_i
      true
    rescue Errno::ESRCH
      false
    end
345267
def kill_all(signal)
      idle, running = partition_workers
      log "kill -#{signal} #{running.map { |r| r.pid }.inspect}"
      running.each { |worker| worker.kill(signal) }
    end
668998
def _close_pidfile(self):
        """"""
        if self._pid_fd is not None:
            os.close(self._pid_fd)
        try:
            os.remove(self.pidfile)
        except OSError as ex:
            if ex.errno != errno.ENOENT:
                raise
1182478
def _kill_process0(self, pid, sig=signal.SIGKILL):
        
        if self._user is None:
            super(RunExecutor, self)._kill_process(pid, sig)
        else:
            logging.debug('Sending signal %s to %s with sudo.', sig, pid)
            try:
                # Cast sig to int, under Python 3.5 the signal.SIG* constants are nums, not ints.
                subprocess.check_call(args=self._build_cmdline(['kill', '-'+str(int(sig)), str(pid)]))
            except subprocess.CalledProcessError as e:
                # may happen for example if process no longer exists
                logging.debug(e)
850373
def kill(self):
        
        if os.path.isfile(self.filename):
            os.remove(self.filename)
        return