aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2017-08-24 15:53:56 +0200
committerMichael Albinus2017-08-24 15:53:56 +0200
commit0332a0ef2bbe6954f080cb6c9d3f0cc2517a1ab1 (patch)
treedd5db1d8637ddc8ac9f4653d012dced23816bf68
parentfa5e63e40412f6152dbe079a766845112d598479 (diff)
downloademacs-0332a0ef2bbe6954f080cb6c9d3f0cc2517a1ab1.tar.gz
emacs-0332a0ef2bbe6954f080cb6c9d3f0cc2517a1ab1.zip
Minor improvements for tramp-interrupt-process, documentation
* doc/lispref/processes.texi (Signals to Processes): * etc/NEWS: Document interrupt-process-functions. * lisp/net/tramp.el (tramp-interrupt-process): Test also for `process-live-p'. * src/process.c (Vinterrupt_process_functions): Fix docstring. * test/lisp/net/tramp-tests.el (tramp-test28-interrupt-process): Extend test.
-rw-r--r--doc/lispref/processes.texi16
-rw-r--r--etc/NEWS10
-rw-r--r--lisp/net/tramp.el2
-rw-r--r--src/process.c4
-rw-r--r--test/lisp/net/tramp-tests.el12
5 files changed, 39 insertions, 5 deletions
diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi
index 292d55d50c5..45e04a5ab88 100644
--- a/doc/lispref/processes.texi
+++ b/doc/lispref/processes.texi
@@ -1351,6 +1351,22 @@ integer); that allows you to send signals to processes that are not
1351children of Emacs. @xref{System Processes}. 1351children of Emacs. @xref{System Processes}.
1352@end deffn 1352@end deffn
1353 1353
1354Sometimes, it is necessary to send a signal to a non-local
1355asynchronous process. This is possible by writing an own
1356@code{interrupt-process} implementation. This function must be added
1357then to @code{interrupt-process-functions}.
1358
1359@defvar interrupt-process-functions
1360This variable is a list of functions to be called for
1361@code{interrupt-process}. The arguments of the functions are the same
1362as for @code{interrupt-process}. These functions are called in the
1363order of the list, until one of them returns non-@code{nil}. The
1364default function, which shall always be the last in this list, is
1365@code{internal-default-interrupt-process}.
1366
1367This is the mechanism, how Tramp implements @code{interrupt-process}.
1368@end defvar
1369
1354@node Output from Processes 1370@node Output from Processes
1355@section Receiving Output from Processes 1371@section Receiving Output from Processes
1356@cindex process output 1372@cindex process output
diff --git a/etc/NEWS b/etc/NEWS
index a9e2f5ae3f1..bf59749a62b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -335,6 +335,13 @@ probability of data corruption due to techniques Emacs uses to recover
335in these situations. 335in these situations.
336 336
337+++ 337+++
338** 'interrupt-process' consults now the list
339'interrupt-process-functions', which function has to be called in
340order to deliver the SIGINT signal. This allows Tramp to send the
341SIGINT signal to remote asynchronous processes. The hitherto existing
342implementation has been moved to 'internal-default-interrupt-process'.
343
344+++
338** File local and directory local variables are now initialized each 345** File local and directory local variables are now initialized each
339time the major mode is set, not just when the file is first visited. 346time the major mode is set, not just when the file is first visited.
340These local variables will thus not vanish on setting a major mode. 347These local variables will thus not vanish on setting a major mode.
@@ -988,6 +995,9 @@ manual documents how to configure ssh and PuTTY accordingly.
988initialization files. 995initialization files.
989 996
990--- 997---
998*** Tramp is able now to send SIGINT to remote asynchronous processes.
999
1000---
991*** Variable 'tramp-completion-mode' is obsoleted. 1001*** Variable 'tramp-completion-mode' is obsoleted.
992 1002
993--- 1003---
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 2aa9a6b9859..ef3e62ccce3 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -4393,7 +4393,7 @@ Only works for Bourne-like shells."
4393 (t process))) 4393 (t process)))
4394 pid) 4394 pid)
4395 ;; If it's a Tramp process, send the INT signal remotely. 4395 ;; If it's a Tramp process, send the INT signal remotely.
4396 (when (and (processp proc) 4396 (when (and (processp proc) (process-live-p proc)
4397 (setq pid (process-get proc 'remote-pid))) 4397 (setq pid (process-get proc 'remote-pid)))
4398 (tramp-message proc 5 "Interrupt process %s with pid %s" proc pid) 4398 (tramp-message proc 5 "Interrupt process %s with pid %s" proc pid)
4399 ;; This is for tramp-sh.el. Other backends do not support this (yet). 4399 ;; This is for tramp-sh.el. Other backends do not support this (yet).
diff --git a/src/process.c b/src/process.c
index e7ee99ab3d9..730caea677f 100644
--- a/src/process.c
+++ b/src/process.c
@@ -8192,8 +8192,8 @@ The variable takes effect when `start-process' is called. */);
8192 Vprocess_adaptive_read_buffering = Qt; 8192 Vprocess_adaptive_read_buffering = Qt;
8193 8193
8194 DEFVAR_LISP ("interrupt-process-functions", Vinterrupt_process_functions, 8194 DEFVAR_LISP ("interrupt-process-functions", Vinterrupt_process_functions,
8195 doc: /* List of functions to be called for `interrupt-function'. 8195 doc: /* List of functions to be called for `interrupt-process'.
8196The arguments of the functions are the same as for `interrupt-function'. 8196The arguments of the functions are the same as for `interrupt-process'.
8197These functions are called in the order of the list, until one of them 8197These functions are called in the order of the list, until one of them
8198returns non-`nil'. */); 8198returns non-`nil'. */);
8199 Vinterrupt_process_functions = list1 (Qinternal_default_interrupt_process); 8199 Vinterrupt_process_functions = list1 (Qinternal_default_interrupt_process);
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 85ed6467220..55f4b52ccdf 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -2966,9 +2966,17 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
2966 (with-temp-buffer 2966 (with-temp-buffer
2967 (setq proc (start-file-process "test" (current-buffer) "sleep" "10")) 2967 (setq proc (start-file-process "test" (current-buffer) "sleep" "10"))
2968 (should (processp proc)) 2968 (should (processp proc))
2969 (should (process-live-p proc))
2969 (should (equal (process-status proc) 'run)) 2970 (should (equal (process-status proc) 'run))
2970 (interrupt-process proc) 2971 (should (interrupt-process proc))
2971 (should (equal (process-status proc) 'signal))) 2972 ;; Let the process accept the interrupt.
2973 (accept-process-output proc 1 nil 0)
2974 (should-not (process-live-p proc))
2975 (should (equal (process-status proc) 'signal))
2976 ;; An interrupted process cannot be interrupted, again.
2977 ;; Does not work reliable.
2978 ;; (should-error (interrupt-process proc)))
2979 )
2972 2980
2973 ;; Cleanup. 2981 ;; Cleanup.
2974 (ignore-errors (delete-process proc))))) 2982 (ignore-errors (delete-process proc)))))