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.
This commit is contained in:
parent
fa5e63e404
commit
0332a0ef2b
5 changed files with 39 additions and 5 deletions
|
@ -1351,6 +1351,22 @@ integer); that allows you to send signals to processes that are not
|
|||
children of Emacs. @xref{System Processes}.
|
||||
@end deffn
|
||||
|
||||
Sometimes, it is necessary to send a signal to a non-local
|
||||
asynchronous process. This is possible by writing an own
|
||||
@code{interrupt-process} implementation. This function must be added
|
||||
then to @code{interrupt-process-functions}.
|
||||
|
||||
@defvar interrupt-process-functions
|
||||
This variable is a list of functions to be called for
|
||||
@code{interrupt-process}. The arguments of the functions are the same
|
||||
as for @code{interrupt-process}. These functions are called in the
|
||||
order of the list, until one of them returns non-@code{nil}. The
|
||||
default function, which shall always be the last in this list, is
|
||||
@code{internal-default-interrupt-process}.
|
||||
|
||||
This is the mechanism, how Tramp implements @code{interrupt-process}.
|
||||
@end defvar
|
||||
|
||||
@node Output from Processes
|
||||
@section Receiving Output from Processes
|
||||
@cindex process output
|
||||
|
|
10
etc/NEWS
10
etc/NEWS
|
@ -334,6 +334,13 @@ These variables are for users who would like to avoid the small
|
|||
probability of data corruption due to techniques Emacs uses to recover
|
||||
in these situations.
|
||||
|
||||
+++
|
||||
** 'interrupt-process' consults now the list
|
||||
'interrupt-process-functions', which function has to be called in
|
||||
order to deliver the SIGINT signal. This allows Tramp to send the
|
||||
SIGINT signal to remote asynchronous processes. The hitherto existing
|
||||
implementation has been moved to 'internal-default-interrupt-process'.
|
||||
|
||||
+++
|
||||
** File local and directory local variables are now initialized each
|
||||
time the major mode is set, not just when the file is first visited.
|
||||
|
@ -987,6 +994,9 @@ manual documents how to configure ssh and PuTTY accordingly.
|
|||
'tramp-remote-process-environment' enables reading of shell
|
||||
initialization files.
|
||||
|
||||
---
|
||||
*** Tramp is able now to send SIGINT to remote asynchronous processes.
|
||||
|
||||
---
|
||||
*** Variable 'tramp-completion-mode' is obsoleted.
|
||||
|
||||
|
|
|
@ -4393,7 +4393,7 @@ Only works for Bourne-like shells."
|
|||
(t process)))
|
||||
pid)
|
||||
;; If it's a Tramp process, send the INT signal remotely.
|
||||
(when (and (processp proc)
|
||||
(when (and (processp proc) (process-live-p 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).
|
||||
|
|
|
@ -8192,8 +8192,8 @@ The variable takes effect when `start-process' is called. */);
|
|||
Vprocess_adaptive_read_buffering = Qt;
|
||||
|
||||
DEFVAR_LISP ("interrupt-process-functions", Vinterrupt_process_functions,
|
||||
doc: /* List of functions to be called for `interrupt-function'.
|
||||
The arguments of the functions are the same as for `interrupt-function'.
|
||||
doc: /* List of functions to be called for `interrupt-process'.
|
||||
The arguments of the functions are the same as for `interrupt-process'.
|
||||
These functions are called in the order of the list, until one of them
|
||||
returns non-`nil'. */);
|
||||
Vinterrupt_process_functions = list1 (Qinternal_default_interrupt_process);
|
||||
|
|
|
@ -2966,9 +2966,17 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
|
|||
(with-temp-buffer
|
||||
(setq proc (start-file-process "test" (current-buffer) "sleep" "10"))
|
||||
(should (processp proc))
|
||||
(should (process-live-p proc))
|
||||
(should (equal (process-status proc) 'run))
|
||||
(interrupt-process proc)
|
||||
(should (equal (process-status proc) 'signal)))
|
||||
(should (interrupt-process proc))
|
||||
;; Let the process accept the interrupt.
|
||||
(accept-process-output proc 1 nil 0)
|
||||
(should-not (process-live-p proc))
|
||||
(should (equal (process-status proc) 'signal))
|
||||
;; An interrupted process cannot be interrupted, again.
|
||||
;; Does not work reliable.
|
||||
;; (should-error (interrupt-process proc)))
|
||||
)
|
||||
|
||||
;; Cleanup.
|
||||
(ignore-errors (delete-process proc)))))
|
||||
|
|
Loading…
Add table
Reference in a new issue