Commit 7fda3941 authored by Michael Albinus's avatar Michael Albinus

Fix `tramp-interrupt-process'

* lisp/net/tramp.el (tramp-interrupt-process): Improve command.

* test/lisp/net/tramp-tests.el (tramp-test06-directory-file-name)
(tramp-test26-file-name-completion): Simplify.
(tramp-test31-interrupt-process): Remove :unstable tag.
parent de1d150a
...@@ -5006,10 +5006,12 @@ name of a process or buffer, or nil to default to the current buffer." ...@@ -5006,10 +5006,12 @@ name of a process or buffer, or nil to default to the current buffer."
(tramp-error proc 'error "Process %s is not active" proc) (tramp-error proc 'error "Process %s is not active" proc)
(tramp-message proc 5 "Interrupt process %s with pid %s" proc 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). ;; 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-compat-funcall
'tramp-send-command 'tramp-send-command
(process-get proc 'vector) (process-get proc 'vector)
(format "kill -2 -%d" pid)) (format "(\\kill -2 -%d || \\kill -2 %d) 2>/dev/null" pid pid))
;; Wait, until the process has disappeared. If it doesn't, ;; Wait, until the process has disappeared. If it doesn't,
;; fall back to the default implementation. ;; fall back to the default implementation.
(while (tramp-accept-process-output proc 0)) (while (tramp-accept-process-output proc 0))
...@@ -5064,10 +5066,5 @@ name of a process or buffer, or nil to default to the current buffer." ...@@ -5064,10 +5066,5 @@ name of a process or buffer, or nil to default to the current buffer."
;; and friends, for most of the handlers this is the major ;; and friends, for most of the handlers this is the major
;; difference between the different backends. Other handlers but ;; difference between the different backends. Other handlers but
;; *-process-file would profit from this as well. ;; *-process-file would profit from this as well.
;;
;; * Get rid of `shell-command'. In its primary implementation, it
;; uses `process-file-shell-command' and
;; `start-file-process-shell-command', which is sufficient due to
;; connection-local `shell-file-name'.
;;; tramp.el ends here ;;; tramp.el ends here
...@@ -2217,11 +2217,10 @@ This checks also `file-name-as-directory', `file-name-directory', ...@@ -2217,11 +2217,10 @@ This checks also `file-name-as-directory', `file-name-directory',
;; Bug#10085. ;; Bug#10085.
(when (tramp--test-enabled) ;; Packages like tramp-gvfs.el might be disabled. (when (tramp--test-enabled) ;; Packages like tramp-gvfs.el might be disabled.
(dolist (n-e '(nil t)) (dolist (non-essential '(nil t))
;; We must clear `tramp-default-method'. On hydra, it is "ftp", ;; We must clear `tramp-default-method'. On hydra, it is "ftp",
;; which ruins the tests. ;; which ruins the tests.
(let ((non-essential n-e) (let ((tramp-default-method
(tramp-default-method
(file-remote-p tramp-test-temporary-file-directory 'method)) (file-remote-p tramp-test-temporary-file-directory 'method))
(host (file-remote-p tramp-test-temporary-file-directory 'host))) (host (file-remote-p tramp-test-temporary-file-directory 'host)))
(dolist (dolist
...@@ -4035,10 +4034,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." ...@@ -4035,10 +4034,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
;; Cleanup. ;; Cleanup.
(tramp-change-syntax orig-syntax)))) (tramp-change-syntax orig-syntax))))
(dolist (n-e '(nil t)) (dolist (non-essential '(nil t))
(dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil))) (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
(let ((non-essential n-e) (let ((tmp-name (tramp--test-make-temp-name nil quoted)))
(tmp-name (tramp--test-make-temp-name nil quoted)))
(unwind-protect (unwind-protect
(progn (progn
...@@ -4419,9 +4417,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." ...@@ -4419,9 +4417,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(ert-deftest tramp-test31-interrupt-process () (ert-deftest tramp-test31-interrupt-process ()
"Check `interrupt-process'." "Check `interrupt-process'."
;; The test fails from time to time, w/o a reproducible pattern. So :tags '(:expensive-test)
;; we mark it as unstable.
:tags '(:expensive-test :unstable)
(skip-unless (tramp--test-enabled)) (skip-unless (tramp--test-enabled))
(skip-unless (tramp--test-sh-p)) (skip-unless (tramp--test-sh-p))
;; Since Emacs 26.1. ;; Since Emacs 26.1.
...@@ -4435,7 +4431,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." ...@@ -4435,7 +4431,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
kill-buffer-query-functions proc) kill-buffer-query-functions proc)
(unwind-protect (unwind-protect
(with-temp-buffer (with-temp-buffer
(setq proc (start-file-process "test" (current-buffer) "sleep" "10")) (setq proc (start-file-process-shell-command
"test" (current-buffer)
"trap 'echo boom; exit 1' 2; sleep 100"))
(should (processp proc)) (should (processp proc))
(should (process-live-p proc)) (should (process-live-p proc))
(should (equal (process-status proc) 'run)) (should (equal (process-status proc) 'run))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment