kill process
    Args:
        process - Popen object for process
485128
def kill_mprocess(process):
    
    if process and proc_alive(process):
        process.terminate()
        process.communicate()
    return not proc_alive(process)
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)
186037
def stop_process(self):
        
        self._process.terminate()
        if not self._process.waitForFinished(100):
            self._process.kill()
887825
def kill(self, procname):
        
        for proc in psutil.process_iter():
            if proc.name() == procname:
                self.info_log(
                    '[pid:%s][name:%s] killed' %
                    (proc.pid, proc.name())
                )
                proc.kill()
729139
def kill_process(process):
    """"""
    logger = logging.getLogger('xenon')
    logger.info('Terminating Xenon-GRPC server.')
    os.kill(process.pid, signal.SIGINT)
    process.wait()
103342
def _AbortKill(self):
    """"""
    for pid, process in iter(self._processes_per_pid.items()):
      if not process.is_alive():
        continue

      logger.warning('Killing process: {0:s} (PID: {1:d}).'.format(
          process.name, pid))
      self._KillProcess(pid)
878933
def kill_all(self, kill_signal, kill_shell=False):
        """"""
        for key in self.processes.keys():
            self.kill_process(key, kill_signal, kill_shell)
1231248
def kill_process_children_unix(pid):
    
    root_process_path = "/proc/{pid}/task/{pid}/children".format(pid=pid)
    if not os.path.isfile(root_process_path):
        return
    with open(root_process_path) as children_list_file:
        children_list_pid = children_list_file.read().split()

    for child_pid in children_list_pid:
        children_proc_path = "/proc/%s/task/%s/children" % (
            child_pid,
            child_pid,
        )
        if not os.path.isfile(children_proc_path):
            continue
        with open(children_proc_path) as children_list_file_2:
            children_list_pid_2 = children_list_file_2.read().split()
        for _pid in children_list_pid_2:
            try:
                os.kill(int(_pid), signal.SIGTERM)
            except ProcessLookupError:
                continue
        try:
            os.kill(int(child_pid), signal.SIGTERM)
        except ProcessLookupError:
            continue
166083
def killProcess(self, pid):
        
        SYNCHRONIZE = 0x00100000
        PROCESS_TERMINATE = 0x0001
        hProcess = self._kernel32.OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, True, pid)
        result = self._kernel32.TerminateProcess(hProcess, 0)
        self._kernel32.CloseHandle(hProcess)
151939
def close(self):
        '''
        '''
        if not self._process:
            return

        if self._process.returncode is not None:
            return

        _logger.debug('Terminate process.')

        try:
            self._process.terminate()
        except OSError as error:
            if error.errno != errno.ESRCH:
                raise

        for dummy in range(10):
            if self._process.returncode is not None:
                return

            time.sleep(0.05)

        _logger.debug('Failed to terminate. Killing.')

        try:
            self._process.kill()
        except OSError as error:
            if error.errno != errno.ESRCH:
                raise
639957
def kill_process(self, payload):
        """"""
        # Kill specific processes, if `keys` is given in the payload
        kill_signal = signals[payload['signal'].lower()]
        kill_shell = payload.get('all', False)
        if payload.get('keys'):
            succeeded = []
            failed = []
            for key in payload.get('keys'):
                success = self.process_handler.kill_process(key, kill_signal, kill_shell)
                if success:
                    succeeded.append(str(key))
                else:
                    failed.append(str(key))

            message = ''
            if len(succeeded) > 0:
                message += "Signal '{}' sent to processes: {}.".format(payload['signal'], ', '.join(succeeded))
                status = 'success'
            if len(failed) > 0:
                message += '\nNo running process for keys: {}'.format(', '.join(failed))
                status = 'error'

            answer = {'message': message.strip(), 'status': status}

        # Kill all processes and the daemon
        else:
            self.process_handler.kill_all(kill_signal, kill_shell)
            if kill_signal == signal.SIGINT or \
               kill_signal == signal.SIGTERM or \
               kill_signal == signal.SIGKILL:
                self.paused = True
            answer = {'message': 'Signal send to all processes.',
                      'status': 'success'}
        return answer
1128994
def _process_kill(self):
        """"""
        if self._process.poll() is None:  # pragma: no cover
            self._process.kill()
            self._process.wait(timeout=5)
590716
def kill(signal)
      Process.kill(signal.to_s, pid) if pid && @self_started
      @killed = true
    rescue Errno::ESRCH => e
      log "Can't kill #{pid}: #{e}"
    end
178475
def stop_process(self):
        
        if self.process is not None:
            self._user_stop = True
            self.process.kill()
            self.setReadOnly(True)
            self._running = False
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('}')
1261254
def isprocess(pid, error=False):
    
    try:
        # Don't worry folks, no processes are harmed in the making of
        # this system call:
        os.kill(pid, 0)
        return True
    except OSError:
        return False
984440
function kill( proc, callback ){
    var arg = isNumber( proc ) ? '/F /PID ' + proc : '/F /IM ' + proc;

    if ( isNumber( proc ) || isString( proc )){
        exec( taskKillPath + arg, function( err ){
            if( callback ) callback( err )
        })
    } else {
        callback( new Error( 'The first kill() argument provided is neither a string nor an integer (not a valid process).' ))
    }
}