// kill kills the target process.
480910
func (dbp *Process) kill() (err error) {
	if dbp.exited {
		return nil
	}
	if !dbp.threads[dbp.pid].Stopped() {
		return errors.New("process must be stopped in order to kill it")
	}
	if err = sys.Kill(-dbp.pid, sys.SIGKILL); err != nil {
		return errors.New("could not deliver signal " + err.Error())
	}
	if _, _, err = dbp.wait(dbp.pid, 0); err != nil {
		return
	}
	dbp.postExit()
	return
}
99747
func (cmd AppCmd) Kill() {

	if cmd.Cmd != nil && (cmd.ProcessState == nil || !cmd.ProcessState.Exited()) {
		// Windows appears to send the kill to all threads, shutting down the
		// server before this can, this check will ensure the process is still running
		if _, err := os.FindProcess(int(cmd.Process.Pid));err!=nil {
			// Server has already exited
			utils.Logger.Info("Killing revel server pid", "pid", cmd.Process.Pid)
			return
		}

		// Send an interrupt signal to allow for a graceful shutdown
		utils.Logger.Info("Killing revel server pid", "pid", cmd.Process.Pid)
		var err error
		if runtime.GOOS == "windows" {
			// os.Interrupt is not available on windows
			err = cmd.Process.Signal(os.Kill)
		} else {
			err = cmd.Process.Signal(os.Interrupt)
		}

		if err != nil {
			utils.Logger.Error(
				"Revel app failed to kill process.",
				"processid", cmd.Process.Pid,"error",err,
				"killerror", cmd.Process.Kill())
			return
		}

		// Wait for the shutdown
		ch := make(chan bool, 1)
		go func() {
			s, err := cmd.Process.Wait()
			defer func() {
				ch <- true
			}()
			if err != nil {
				utils.Logger.Info("Wait failed for process ", "error", err)
			}
			if s != nil {
				utils.Logger.Info("Revel App exited", "state", s.String())
			}
		}()

		// Use a timer to ensure that the process exits
		utils.Logger.Info("Waiting to exit")
		select {
		case <-ch:
			return
		case <-time.After(60 * time.Second):
			// Kill the process
			utils.Logger.Error(
				"Revel app failed to exit in 60 seconds - killing.",
				"processid", cmd.Process.Pid,
				"killerror", cmd.Process.Kill())
		}

		utils.Logger.Info("Done Waiting to exit")
	}
}
1288573
func (k *K8sAPIExecutor) Kill(containerIDs []string) error {
	log.Infof("Killing containers %s", containerIDs)
	for _, containerID := range containerIDs {
		err := k.client.killGracefully(containerID)
		if err != nil {
			return err
		}
	}
	return nil
}
1334990
func (p *Process) Kill() error {
	if err := p.forceStopProcess(); err != nil {
		return err
	}
	p.log.Debugf("Process %s was forced to stop (last PID: %d)", p.GetName(), p.GetPid())
	return nil
}
827401
func (s *Service) Kill(ctx context.Context, r *shimapi.KillRequest) (*ptypes.Empty, error) {
	if r.ID == "" {
		p, err := s.getInitProcess()
		if err != nil {
			return nil, err
		}
		if err := p.Kill(ctx, r.Signal, r.All); err != nil {
			return nil, errdefs.ToGRPC(err)
		}
		return empty, nil
	}

	p, err := s.getExecProcess(r.ID)
	if err != nil {
		return nil, err
	}
	if err := p.Kill(ctx, r.Signal, r.All); err != nil {
		return nil, errdefs.ToGRPC(err)
	}
	return empty, nil
}
234914
func (pid *PID) Kill() error {
	proc, err := pid.Process()
	if err != nil {
		return err
	}

	return proc.Kill()
}
1226545
func (tr *TaskRunner) Kill(ctx context.Context, event *structs.TaskEvent) error {
	tr.logger.Trace("Kill requested", "event_type", event.Type, "event_reason", event.KillReason)

	// Cancel the task runner to break out of restart delay or the main run
	// loop.
	tr.killCtxCancel()

	// Emit kill event
	tr.EmitEvent(event)

	select {
	case <-tr.WaitCh():
	case <-ctx.Done():
		return ctx.Err()
	}

	return tr.getKillErr()
}
1014037
func ProjectKill(p project.APIProject, c *cli.Context) error {
	err := p.Kill(context.Background(), c.String("signal"), c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	return nil
}
966148
func KillProcesses(endpoint string, whiteUsers ...string) error {
	var inst *Instance
	var exists bool
	if inst, exists = connectionPool[endpoint]; !exists {
		return errNotRegistered
	}
	var processes []Process
	var err error
	if processes, err = GetProcessList(endpoint); err != nil {
		return err
	}
	var isWhiteUser bool
	for _, process := range processes {
		isWhiteUser = false
		for _, name := range whiteUsers {
			if process.User == name {
				isWhiteUser = true
				break
			}
		}
		if !isWhiteUser {
			inst.connection.Exec("KILL ?", process.ID)
		}
	}
	return nil
}
1045242
func (conn *gdbConn) kill() error {
	resp, err := conn.exec([]byte{'$', 'k'}, "kill")
	if err == io.EOF {
		// The stub is allowed to shut the connection on us immediately after a
		// kill. This is not an error.
		conn.conn.Close()
		conn.conn = nil
		return proc.ErrProcessExited{Pid: conn.pid}
	}
	if err != nil {
		return err
	}
	_, _, err = conn.parseStopPacket(resp, "", nil)
	return err
}
1115359
func (k8s *Kubernetes) Kill(qorJob worker.QorJobInterface) error {
	var (
		k8sJob, err = k8s.GetJobSpec(qorJob)
		jobName     = fmt.Sprintf("qor-job-%v", qorJob.GetJobID())
	)

	if err == nil {
		return k8s.Clientset.Batch().Jobs(k8sJob.ObjectMeta.GetNamespace()).Delete(jobName, &metav1.DeleteOptions{})
	}
	return err
}
385230
func KillMountProcess() error {
	out, err := ioutil.ReadFile(filepath.Join(constants.GetMinipath(), constants.MountProcessFileName))
	if err != nil {
		return nil // no mount process to kill
	}
	pid, err := strconv.Atoi(string(out))
	if err != nil {
		return errors.Wrap(err, "error converting mount string to pid")
	}
	mountProc, err := os.FindProcess(pid)
	if err != nil {
		return errors.Wrap(err, "error converting mount string to pid")
	}
	return mountProc.Kill()
}
618860
func (lk *consulLock) Kill() error {
	lk.mutex.Lock()
	defer lk.mutex.Unlock()

	// Send stop signal on stop channel
	close(lk.stopChan)

	// Mark this as released
	lk.isReleased = true

	return nil
}
1090468
func (c *Container) Kill() error {
	dc, err := getDockerClient()
	if err != nil {
		return err
	}
	return dc.KillContainer(dockerclient.KillContainerOptions{ID: c.ID, Signal: dockerclient.SIGKILL})
}
145265
func (daemon *Daemon) ContainerKill(name string, sig uint64) error {
	container, err := daemon.GetContainer(name)
	if err != nil {
		return err
	}

	if sig != 0 && !signal.ValidSignalForPlatform(syscall.Signal(sig)) {
		return fmt.Errorf("The %s daemon does not support signal %d", runtime.GOOS, sig)
	}

	// If no signal is passed, or SIGKILL, perform regular Kill (SIGKILL + wait())
	if sig == 0 || syscall.Signal(sig) == syscall.SIGKILL {
		return daemon.Kill(container)
	}
	return daemon.killWithSignal(container, int(sig))
}
781523
func (m *Manager) Kill() error {
	m.lock.Lock()
	defer m.lock.Unlock()

	return m.stop(func(p Proxy) error {
		return p.Stop()
	})
}
614033
func (_Chequebook *ChequebookTransactor) Kill(opts *bind.TransactOpts) (*types.Transaction, error) {
	return _Chequebook.contract.Transact(opts, "kill")
}