Function: eshell/kill

eshell/kill is a byte-compiled function defined in esh-proc.el.gz.

Signature

(eshell/kill &rest ARGS)

Documentation

Kill processes.

Usage: kill [-<signal>] <pid>|<process> ... Accepts PIDs and process objects. Optionally accept signals and signal names.

Probably introduced at or before Emacs version 27.1.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-proc.el.gz
(defun eshell/kill (&rest args)
  "Kill processes.
Usage: kill [-<signal>] <pid>|<process> ...
Accepts PIDs and process objects.  Optionally accept signals
and signal names."
  (let ((signum 'SIGINT))
    (let ((arg (car args))
          (case-fold-search nil))
      (when (stringp arg)
        ;; If the first argument starts with a dash, treat it as the
        ;; signal specifier.
        (cond
         ((string-match "\\`-[[:digit:]]+\\'" arg)
          (setq signum (abs (string-to-number arg)))
          (pop args))
         ((string-match "\\`-\\([[:upper:]]+\\|[[:lower:]]+\\)\\'" arg)
          (setq signum (intern (substring arg 1)))
          (pop args)))))
    (dolist (proc args)
      (when (stringp proc)
        (setq proc (string-to-number proc)))
      (let ((result
             (cond
              ((numberp proc)
               (when (<= proc 0)
                 (error "kill: bad pid: %d" proc))
               (signal-process proc signum (file-remote-p default-directory)))
              ((eshell-processp proc)
               (signal-process proc signum))
              (t
               (error "kill: invalid argument type: %s" (type-of proc))))))
        (when (= result -1)
          (error "kill: failed to kill process %s" proc))))))