/*
this one called by dying/killed process
433141
void exit(final OtpErlangPid from, final OtpErlangPid to,
            final OtpErlangObject reason) {
        try {
            super.sendExit(from, to, reason);
        } catch (final Exception e) {
        }
    }
172504
function main(args, pid) {
  if (args.length <3) {
    console.log('Usage: fuck [you] PROCESS_NAME');
    process.exit(1);
  }

  var pattern   = last(args).get();
  var processes = ps.list();
  var killed    = processes.map(function(data) {
                    return data.filter(match(pid, pattern))
                               .map(kill);
                  });

  killed.chain(sequence(Task)).map(collectUnique).fork(
    function onError(e) {
      console.log('');
      shock('It’s not very effective...');
    },
    function onSuccess(xs) {
      console.log('');
      if (xs.length > 0)
        xs.forEach(function(process){
          rage(flip(process.name), '(x', process.pids.length, ': ', process.pids.join(', '), ')');
        });
      else
        shock('I’ve got nothing on ', pattern);
    }
  );
}
249702
public void kill() {
    boolean killNow = false;
    synchronized(jobInitKillStatus) {
      jobInitKillStatus.killed = true;
      //if not in middle of init, terminate it now
      if(!jobInitKillStatus.initStarted || jobInitKillStatus.initDone) {
        //avoiding nested locking by setting flag
        killNow = true;
      }
    }
    if(killNow) {
      terminate(JobStatus.KILLED);
    }
  }
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
1103570
def _KillProcess(self, pid):
    
    if sys.platform.startswith('win'):
      process_terminate = 1
      handle = ctypes.windll.kernel32.OpenProcess(
          process_terminate, False, pid)
      ctypes.windll.kernel32.TerminateProcess(handle, -1)
      ctypes.windll.kernel32.CloseHandle(handle)

    else:
      try:
        os.kill(pid, signal.SIGKILL)
      except OSError as exception:
        logger.error('Unable to kill process {0:d} with error: {1!s}'.format(
            pid, exception))
308665
function terminate(control)
{
  if (control && control._process && typeof control._process.kill == 'function')
  {
    control._process._executioner_killRequested = true;
    control._process.kill();
    return true;
  }

  return false;
}
485128
def kill_mprocess(process):
    
    if process and proc_alive(process):
        process.terminate()
        process.communicate()
    return not proc_alive(process)
228003
function abort() {
    var event,
        me = this,
        resetting = calledBy.reset;

    if (me.running) {
      event = Event('abort');
      me.emit(event);
      if (!event.cancelled || resetting) {
        // avoid infinite recursion
        calledBy.abort = true;
        me.reset();
        delete calledBy.abort;

        if (support.timeout) {
          clearTimeout(me._timerId);
          delete me._timerId;
        }
        if (!resetting) {
          me.aborted = true;
          me.running = false;
        }
      }
    }
    return me;
  }
615828
function () {
    const oThis = this
    ;

    oThis.snmData.lastProcessedBlock = oThis.toBlock;

    fs.writeFileSync(
      oThis.filePath,
      JSON.stringify(oThis.snmData),
      function (err) {
        if (err)
          logger.error(err);
      }
    );

    if (oThis.interruptSignalObtained) {
      logger.info('Exiting Process....');
      process.exit(1);
    }
  }
410589
protected function _killPid()
    {
        if (file_exists($this->_pidFile)) {
            unlink($this->_pidFile);
        }
        if ($this->_pid) {
            posix_kill($this->_pid, SIGTERM);
        }
    }
669836
def stop(kill_arg=nil)
      if self.daemon_running?
        kill_pid(kill_arg || options[:kill])
        
        if until_true(MAX_START_TRIES) { self.daemon_stopped? }
          FileUtils.rm options[:pid_path] # Only kill if we stopped the daemon
          log "Daemonized process killed after term."
        else
          log "Failed to kill daemonized process"
          if options[:force]
            kill_pid(kill_arg || options[:kill], 'KILL')

            if until_true(MAX_START_TRIES) { self.daemon_stopped? }
              FileUtils.rm options[:pid_path] # Only kill if we stopped the daemon
              log "Daemonized process killed after kill."
            end
          end
        end
      else # not running
        log "No #{@name} processes are running"
        false
      end
    end
86121
public void kill() {
        die = true;
        lock.activate(); // wake up the sleeping thread.

        // wait for it to die. if someone interrupts us, process that later.
        try {
            join();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    }
426141
def kill(self):
        
        if self.process:
            self.process.kill()
            self.process.wait()
861891
function kill(i) {
    if(dead[i]) {
      return
    }
    //Kill vertex
    dead[i] = true
    //Fixup topology
    var s = inv[i]
    var t = outv[i]
    if(inv[t] >= 0) {
      inv[t] = s
    }
    if(outv[s] >= 0) {
      outv[s] = t
    }

    //Update weights on s and t
    if(index[s] >= 0) {
      heapUpdate(index[s], computeWeight(s))
    }
    if(index[t] >= 0) {
      heapUpdate(index[t], computeWeight(t))
    }
  }
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")
557974
private void killTask(TaskAttemptID tid, String msg, boolean wasFailure) {
    // Kill the task and mark it as killed.
    taskTracker.cleanUpOverMemoryTask(tid, wasFailure, msg);
    // Now destroy the ProcessTree, remove it from monitoring map.
    CGroupProcessTreeInfo ptInfo = processTreeInfoMap.get(tid);
    try {
      LinuxSystemCall.killProcessGroup(Integer.parseInt(ptInfo.getPID()));
    } catch (java.io.IOException e) {
      LOG.error("Could not kill process group " + ptInfo.getPID(), e);
    }
    processTreeInfoMap.remove(tid);
    LOG.info("Removed ProcessTree with root " + ptInfo.getPID());
  }
945601
public void shutdown() {
        shutdownCalled = true;
        if (isRunning()) {
            watchdog.waitForProcessStarted();
            watchdog.destroyProcess();
            watchdog.waitForTerminationAfterDestroy(2, SECONDS);
            if (isRunning()) {
                watchdog.destroyProcessForcefully();
                watchdog.waitForTerminationAfterDestroy(1, SECONDS);
                if (isRunning()) {
                    LOGGER.severe(String.format("Unable to kill process with PID %s", watchdog.getProcessId()));
                }
            }
        }

        // if shutdown() was called by something other than the shutdown hook, we don't need the shutdown hook anymore
        try {
            if (shutDownHook != null) {
                Runtime.getRuntime().removeShutdownHook(shutDownHook);
            }
        } catch (IllegalStateException e) {
            // ignore.. happens when the shutdown hook is in use, that's okay
        }

    }