Function: tramp-signal-process

tramp-signal-process is a byte-compiled function defined in tramp.el.gz.

Signature

(tramp-signal-process PROCESS SIGCODE &optional REMOTE)

Documentation

Send PROCESS the signal with code SIGCODE.

PROCESS may also be a number specifying the process id of the process to signal; in this case, the process need not be a child of this Emacs. If PROCESS is a process object which contains the property remote-pid, or PROCESS is a number and REMOTE is a remote file name, PROCESS is interpreted as process on the respective remote host, which will be the process to signal. If PROCESS is a string, it is interpreted as process object with the respective process name, or as a number. SIGCODE may be an integer, or a symbol whose name is a signal name.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
(defun tramp-signal-process (process sigcode &optional remote)
  "Send PROCESS the signal with code SIGCODE.
PROCESS may also be a number specifying the process id of the
process to signal; in this case, the process need not be a child of
this Emacs.
If PROCESS is a process object which contains the property
`remote-pid', or PROCESS is a number and REMOTE is a remote file name,
PROCESS is interpreted as process on the respective remote host, which
will be the process to signal.
If PROCESS is a string, it is interpreted as process object with
the respective process name, or as a number.
SIGCODE may be an integer, or a symbol whose name is a signal name."
  (when (stringp process)
    (setq process (or (get-process process)
		      (and (string-match-p (rx bol (+ digit) eol) process)
			   (string-to-number process))
		      (signal 'wrong-type-argument (list #'processp process)))))
  (let (pid vec)
    (cond
     ((processp process)
      (setq pid (process-get process 'remote-pid)
            vec (process-get process 'tramp-vector)))
     ((numberp process)
      (setq pid process
            vec (and (stringp remote) (tramp-dissect-file-name remote))))
     (t (signal 'wrong-type-argument (list #'processp process))))
    (cond
     ((symbolp sigcode)
      (setq sigcode (upcase (symbol-name sigcode)))
      (when (string-prefix-p "SIG" sigcode)
        (setq sigcode (substring sigcode 3))))
     ((not (numberp sigcode))
      (signal 'wrong-type-argument (list #'numberp sigcode))))
    ;; If it's a Tramp process, send SIGCODE remotely.
    (when (and pid vec)
      (tramp-message
       vec 5 "Send signal %s to process %s with pid %s" sigcode process pid)
      ;; This is for tramp-sh.el.  Other backends do not support this (yet).
      (if (tramp-compat-funcall
           'tramp-send-command-and-check
           vec (format "\\kill -%s %d" sigcode pid))
          0 -1))))