method is called to kill a running process
334759
def kill_process(process_name):
    
    try:
        sys.stdout.write('killing: {0} {{ \n'.format(process_name))
        pid = get_process_pid(process_name)
        if pid is not None and psutil.pid_exists(int(pid)):
            p = psutil.Process(pid)
            p.kill()
            p.wait()
            remove_pid_file(process_name)
    except Exception as e:
        sys.stderr.write('Exception on killing {0} : {1} \n'.format(process_name, e))
    finally:
        sys.stdout.write('}')
1123343
def kill(self):
        

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

        self.stop_watch()
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)
730473
function signalKill(childProcess, callback) {
  childProcess.emit('signalKill');
  if (IS_WINDOWS) {
    const taskkill = spawn('taskkill', ['/F', '/T', '/PID', childProcess.pid]);
    taskkill.on('exit', (exitStatus) => {
      if (exitStatus) {
        return callback(
          new Error(`Unable to forcefully terminate process ${childProcess.pid}`)
        );
      }
      callback();
    });
  } else {
    childProcess.kill('SIGKILL');
    process.nextTick(callback);
  }
}
543877
def kill(self, sig):
        '''
        '''
        if sys.platform == 'win32':
            if sig in [signal.SIGINT, signal.CTRL_C_EVENT]:
                sig = signal.CTRL_C_EVENT
            elif sig in [signal.SIGBREAK, signal.CTRL_BREAK_EVENT]:
                sig = signal.CTRL_BREAK_EVENT
            else:
                sig = signal.SIGTERM

        os.kill(self.proc.pid, sig)
186037
def stop_process(self):
        
        self._process.terminate()
        if not self._process.waitForFinished(100):
            self._process.kill()
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
178475
def stop_process(self):
        
        if self.process is not None:
            self._user_stop = True
            self.process.kill()
            self.setReadOnly(True)
            self._running = False
1333654
public void kill() {

        if (m_shell != null) {
            m_shell.exit();
        }
        if (m_loggingThread != null) {
            m_loggingThread.stopThread();
        }
        m_shell = null;
        m_setupBean = null;
    }
1159694
public static int destroyProcess(final Process process) throws InterruptedException {
        if (process == null)
            return 0;
        process.destroy();
        return process.waitFor();
    }
955060
def kill_all_process(self):
    
    if (runtime.get_active_config("cleanup_pending_process",False)):
      for process in self.get_processes():
        self.terminate(process.unique_id)
1303206
def kill(self):
        

        logger.info("Killing external module (pid=%d) for module %s...",
                    self.process.pid, self.name)
        if os.name == 'nt':
            self.process.terminate()
        else:
            self.process.terminate()
            # Wait for 10 seconds before killing the process abruptly
            self.process.join(timeout=KILL_TIME)
            # You do not let me another choice guy...
            if self.process.is_alive():
                logger.warning("%s is still living %d seconds after a normal kill, "
                               "I help it to die", self.name, KILL_TIME)
                os.kill(self.process.pid, signal.SIGKILL)
                self.process.join(1)
                if self.process.is_alive():
                    logger.error("%s still living after brutal kill, I leave it.", self.name)
            logger.info("External module killed")
392579
private function killExistingFpm(): void
    {
        // Never seen this happen but just in case
        if (! file_exists(self::PID_FILE)) {
            unlink(self::SOCKET);
            return;
        }

        $pid = (int) file_get_contents(self::PID_FILE);

        // Never seen this happen but just in case
        if ($pid <= 0) {
            echo "PHP-FPM's PID file contained an invalid PID, assuming PHP-FPM isn't running.\n";
            unlink(self::SOCKET);
            unlink(self::PID_FILE);
            return;
        }

        // Check if the process is running
        if (posix_getpgid($pid) === false) {
            // PHP-FPM is not running anymore, we can cleanup
            unlink(self::SOCKET);
            unlink(self::PID_FILE);
            return;
        }

        echo "PHP-FPM seems to be running already, this might be because Lambda stopped the bootstrap process but didn't leave us an opportunity to stop PHP-FPM. Stopping PHP-FPM now to restart from a blank slate.\n";

        // PHP-FPM is running, let's try to kill it properly
        $result = posix_kill($pid, SIGTERM);
        if ($result === false) {
            echo "PHP-FPM's PID file contained a PID that doesn't exist, assuming PHP-FPM isn't running.\n";
            unlink(self::SOCKET);
            unlink(self::PID_FILE);
            return;
        }

        $this->waitUntilStopped($pid);
        unlink(self::SOCKET);
        unlink(self::PID_FILE);
    }
840553
def terminate(self, force=False):
        ''' '''

        if not self.isalive():
            return True
        try:
            self.kill(signal.SIGHUP)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            self.kill(signal.SIGCONT)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            self.kill(signal.SIGINT)
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            if force:
                self.kill(signal.SIGKILL)
                time.sleep(self.delayafterterminate)
                if not self.isalive():
                    return True
                else:
                    return False
            return False
        except OSError:
            # I think there are kernel timing issues that sometimes cause
            # this to happen. I think isalive() reports True, but the
            # process is dead to the kernel.
            # Make one last attempt to see if the kernel is up to date.
            time.sleep(self.delayafterterminate)
            if not self.isalive():
                return True
            else:
                return False
571384
private void terminateWindowsProcess(InstanceConfiguration config)
    {
        log.info("Cleaning up at application shutdown...");

        String pid;
        try
        {
            pid = ProcessUtil.getElasticsearchPid(config.getBaseDir());
            log.debug("Read PID '" + pid + "' from pid file");
        }
        catch (Exception ex)
        {
            log.debug("Cannot read the PID from file; assuming the process is not running", ex);
            return;
        }
        
        boolean isAlive;
        try
        {
            isAlive = ProcessUtil.isWindowsProcessAlive(config, pid);
            log.debug("Process is still running: " + isAlive);
        }
        catch (Exception ex)
        {
            log.debug("Cannot determine if the process is running; assuming it is", ex);
            isAlive = true;
        }
        
        if (isAlive == false)
        {
            return;
        }
        
        log.info(String.format(
                "The Elasticsearch process [%d] is still running; stopping it...",
                config.getId()));
        
        CommandLine command = ProcessUtil.buildKillCommandLine(pid);
        for (int retry = 0; retry < 3; ++retry)
        {
            try
            {
                ProcessUtil.executeScript(config, command, true);
    
                log.info(String.format(
                        "... the Elasticsearch process [%d] has stopped.",
                        config.getId()));
                ProcessUtil.cleanupPid(config.getBaseDir());
            }
            catch (Exception e)
            {
                if (e.getMessage().contains("no running instance"))
                {
                    log.info(String.format(
                            "... the Elasticsearch process [%d] has stopped.",
                            config.getId()));
                    ProcessUtil.cleanupPid(config.getBaseDir());
                }
                else
                {
                    // sometimes taskkill fails with "The operation attempted is not supported."
                    // https://blogs.technet.microsoft.com/markrussinovich/2005/08/17/unkillable-processes/
                    // in that case, retry
                    if (retry < 2) {
                        try {
                            Thread.sleep(500);
                            continue;
                        } catch (InterruptedException e1) {
                            /* ignore */
                        }
                    }
                    log.error(String.format(
                            "Error while destroying the Elasticsearch process [%d]",
                            config.getId()),
                            e);
                }
            }
            break;
        }
    }
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).' ))
    }
}
729139
def kill_process(process):
    """"""
    logger = logging.getLogger('xenon')
    logger.info('Terminating Xenon-GRPC server.')
    os.kill(process.pid, signal.SIGINT)
    process.wait()