Function: tramp-interrupt-process
tramp-interrupt-process is a byte-compiled function defined in
tramp.el.gz.
Signature
(tramp-interrupt-process &optional PROCESS CURRENT-GROUP)
Documentation
Interrupt remote PROCESS.
PROCESS can be a process, a buffer with an associated process, the name of a process or buffer, or nil to default to the current buffer.
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
;;; Signal handling. This works for remote processes, which have set
;;; the process property `remote-pid'.
(defun tramp-interrupt-process (&optional process _current-group)
"Interrupt remote PROCESS.
PROCESS can be a process, a buffer with an associated process, the
name of a process or buffer, or nil to default to the current buffer."
;; CURRENT-GROUP is not implemented yet.
(let ((proc (cond
((processp process) process)
((bufferp process) (get-buffer-process process))
((stringp process) (or (get-process process)
(get-buffer-process process)))
((null process) (get-buffer-process (current-buffer)))
(t process)))
pid)
;; If it's a Tramp process, send the INT signal remotely.
(when (and (processp proc) (setq pid (process-get proc 'remote-pid)))
(if (not (process-live-p proc))
(tramp-error proc 'error "Process %s is not active" proc)
(tramp-message proc 5 "Interrupt process %s with pid %s" proc pid)
;; This is for tramp-sh.el. Other backends do not support this (yet).
;; Not all "kill" implementations support process groups by
;; negative pid, so we try both variants.
(tramp-compat-funcall
'tramp-send-command
(process-get proc 'tramp-vector)
(format "(\\kill -2 -%d || \\kill -2 %d) 2>%s"
pid pid
(tramp-get-remote-null-device
(process-get proc 'tramp-vector))))
;; Wait, until the process has disappeared. If it doesn't,
;; fall back to the default implementation.
(while (tramp-accept-process-output proc))
(not (process-live-p proc))))))