summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2017-08-21 17:30:33 +0200
committerMichael Albinus <michael.albinus@gmx.de>2017-08-21 17:30:33 +0200
commit01844e40dc43baf1fdc088ef6400343e908ea449 (patch)
tree65ffb9b54340522908591de90a01f402b6226b8d /lisp
parent76fbe2f4541b11af8bcb0b5e57bb155b796b8d8e (diff)
downloademacs-01844e40dc43baf1fdc088ef6400343e908ea449.tar.gz
emacs-01844e40dc43baf1fdc088ef6400343e908ea449.tar.bz2
emacs-01844e40dc43baf1fdc088ef6400343e908ea449.zip
Implement `interrupt-process-functions'
* lisp/net/tramp.el (tramp-interrupt-process): Rename from `tramp-advice-interrupt-process'. Adapt according to changed API. (top): Add it to `interrupt-process-functions'. * src/process.c (Finternal_default_interrupt_process): New defun. (Finterrupt_process): Change implementation, based on Vinterrupt_process_functions. (Vinterrupt_process_functions): New defvar. * test/lisp/net/tramp-tests.el (tramp-test40-unload): Do not test removal of advice.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/tramp.el53
1 files changed, 28 insertions, 25 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 3469d45ff2a..2aa9a6b9859 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -4381,33 +4381,36 @@ Only works for Bourne-like shells."
;;; Signal handling. This works for remote processes, which have set
;;; the process property `remote-pid'.
-(defun tramp-advice-interrupt-process (orig-fun &rest args)
+(defun tramp-interrupt-process (&optional process _current-group)
"Interrupt remote process PROC."
- (let* ((arg0 (car args))
- (proc (cond
- ((processp arg0) arg0)
- ((bufferp arg0) (get-buffer-process arg0))
- ((stringp arg0) (or (get-process arg0)
- (get-buffer-process arg0)))
- ((null arg0) (get-buffer-process (current-buffer)))
- (t arg0)))
- pid)
+ ;; 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.
- (if (and (processp proc)
- (setq pid (process-get proc 'remote-pid)))
- (progn
- (tramp-message proc 5 "%s %s" proc pid)
- (tramp-send-command
- (tramp-get-connection-property proc "vector" nil)
- (format "kill -2 %d" pid)))
- ;; Otherwise, just run the original function.
- (apply orig-fun args))))
-
-(advice-add 'interrupt-process :around 'tramp-advice-interrupt-process)
-(add-hook
- 'tramp-unload-hook
- (lambda ()
- (advice-remove 'interrupt-process 'tramp-advice-interrupt-process)))
+ (when (and (processp proc)
+ (setq pid (process-get proc 'remote-pid)))
+ (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).
+ (tramp-compat-funcall
+ 'tramp-send-command
+ (tramp-get-connection-property proc "vector" nil)
+ (format "kill -2 %d" pid))
+ ;; Report success.
+ proc)))
+
+;; `interrupt-process-functions' exists since Emacs 26.1.
+(when (boundp 'interrupt-process-functions)
+ (add-hook 'interrupt-process-functions 'tramp-interrupt-process)
+ (add-hook
+ 'tramp-unload-hook
+ (lambda ()
+ (remove-hook 'interrupt-process-functions 'tramp-interrupt-process))))
;;; Integration of eshell.el: