Kill the given process and properly closes any pipes connected to it.
506569
async def _cleanup_subprocess(self, process):
        
        if process.returncode is None:
            try:
                process.kill()
                return await asyncio.wait_for(process.wait(), 1)
            except concurrent.futures.TimeoutError:
                self._log.debug('Waiting for process to close failed, may have zombie process.')
            except ProcessLookupError:
                pass
            except OSError:
                if os.name != 'nt':
                    raise
        elif process.returncode > 0:
            raise TSharkCrashException('TShark seems to have crashed (retcode: %d). '
                                       'Try rerunning in debug mode [ capture_obj.set_debug() ] or try updating tshark.'
                                       % process.returncode)
539482
def close(self, terminate=True, kill=False):
        '''
        
        '''
        if not self.closed:
            if self.child_fd is not None:
                os.close(self.child_fd)
                self.child_fd = None
            if self.child_fde is not None:
                os.close(self.child_fde)
                self.child_fde = None
            time.sleep(0.1)
            if terminate:
                if not self.terminate(kill):
                    raise TerminalException('Failed to terminate child process.')
            self.closed = True
1016934
public function terminate($sig = null)
    {
        // Terminates application without reading anything more.
        foreach ($this->pipes as $key => $res) {
            $this->close($key);
        }
        $this->debug('process terminated');
        proc_terminate($this->process, $sig);
    }
976434
def close(self):
        """"""
        if not self.is_running:
            return

        self._state = CLOSED

        self.logger.debug('killing %d worker(s)', len(self._killables))
        self._killables.kill(block=False)

        self.logger.debug('closing %d connection(s)', len(self._connections))
        for conn in self._connections:
            conn.close_stream()

        self.on_close.send(self)
978980
def stop_process(process):
    """"""
    process.terminate()
    process.join(3)

    if process.is_alive() and os.name != 'nt':
        try:
            os.kill(process.pid, signal.SIGKILL)
            process.join()
        except OSError:
            return

    if process.is_alive():
        raise RuntimeError("Unable to terminate PID %d" % os.getpid())
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()
485128
def kill_mprocess(process):
    
    if process and proc_alive(process):
        process.terminate()
        process.communicate()
    return not proc_alive(process)
945252
async function kill(pid) {
  try {
    process.kill(pid, 'SIGTERM')
  } catch (err) {
    if (err.code !== 'ESRCH') throw err
  }
}
1110505
def stop(pid):
    
    if psutil.pid_exists(pid):
      try:
        p = psutil.Process(pid)
        p.kill()
      except Exception:
        pass
878933
def kill_all(self, kill_signal, kill_shell=False):
        """"""
        for key in self.processes.keys():
            self.kill_process(key, kill_signal, kill_shell)
356554
def kill(self, dwExitCode = 0):
        
        hProcess = self.get_handle(win32.PROCESS_TERMINATE)
        win32.TerminateProcess(hProcess, dwExitCode)
1196905
public static void killProcess(String pid) {
        synchronized (lock) {
            LOG.info("Begin to kill process " + pid);

            WorkerShutdown shutdownHandle = getProcessHandle(pid);

            if (shutdownHandle != null) {
                shutdownHandle.shutdown();
            }

            processMap.remove(pid);

            LOG.info("Successfully killed process " + pid);
        }
    }
497132
def kill_proc_tree(pid, sig=signal.SIGTERM, include_parent=True,
                   timeout=None, on_terminate=None):
    
    if pid == os.getpid():
        raise RuntimeError("I refuse to kill myself")
    parent = psutil.Process(pid)
    children = parent.children(recursive=True)
    if include_parent:
        children.append(parent)
    for p in children:
        p.send_signal(sig)
    gone, alive = psutil.wait_procs(children, timeout=timeout,
                                    callback=on_terminate)
    return (gone, alive)
386116
def stop(self):
        
        if self.log_file != PIPE and not (self.log_file == DEVNULL and _HAS_NATIVE_DEVNULL):
            try:
                self.log_file.close()
            except Exception:
                pass

        if self.process is None:
            return

        try:
            self.send_remote_shutdown_command()
        except TypeError:
            pass

        try:
            if self.process:
                for stream in [self.process.stdin,
                               self.process.stdout,
                               self.process.stderr]:
                    try:
                        stream.close()
                    except AttributeError:
                        pass
                self.process.terminate()
                self.process.wait()
                self.process.kill()
                self.process = None
        except OSError:
            pass
1123343
def kill(self):
        

        for process in list(self.processes):
            process["subprocess"].send_signal(signal.SIGKILL)

        self.stop_watch()
173658
def _terminate_service(self):
        """"""
        with self.__lock:
            if self._service:
                self._service.terminate()
            if self._pipe_commands:
                self._pipe_commands.close()
            if self._pipe_service:
                self._pipe_service.close()
            self._pipe_commands = None
            self._pipe_service = None
            self._service_class_name = None
            self._service_name = None
            if self._service_status != CommonService.SERVICE_STATUS_TEARDOWN:
                self.update_status(status_code=CommonService.SERVICE_STATUS_END)
            if self._service:
                self._service.join()  # must wait for process to be actually destroyed
            self._service = None
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()