From de5f59219ac02c6502907f6a24538ddabf487839 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Thu, 7 May 2020 10:27:14 +0200 Subject: [PATCH] Handle signals in Tramp's process-file * lisp/net/tramp-adb.el (tramp-adb-handle-process-file): * lisp/net/tramp-sh.el (tramp-sh-handle-process-file): Handle signals. * test/lisp/net/tramp-tests.el (tramp-test28-process-file): Adapt test. --- lisp/net/tramp-adb.el | 4 ++++ lisp/net/tramp-sh.el | 4 ++++ test/lisp/net/tramp-tests.el | 2 ++ 3 files changed, 10 insertions(+) diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 7f829f15205..7ef07afb8ef 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -918,6 +918,10 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." (kill-buffer (tramp-get-connection-buffer v)) (setq ret 1))) + ;; Handle signals. + (when (and (natnump ret) (> ret 128)) + (setq ret (format "Signal %d" (- ret 128)))) + ;; Provide error file. (when tmpstderr (rename-file tmpstderr (cadr destination) t)) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index c6eb7a8ff49..c609f58cdd8 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -3159,6 +3159,10 @@ STDERR can also be a file name." (kill-buffer (tramp-get-connection-buffer v)) (setq ret 1))) + ;; Handle signals. + (when (and (natnump ret) (> ret 128)) + (setq ret (format "Signal %d" (- ret 128)))) + ;; Provide error file. (when tmpstderr (rename-file tmpstderr (cadr destination) t)) diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 462539a7c17..4cacfa2f712 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -4209,6 +4209,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (should-not (zerop (process-file "false"))) (should-not (zerop (process-file "binary-does-not-exist"))) (should (= 42 (process-file "sh" nil nil nil "-c" "exit 42"))) + ;; Return string in case the process is interrupted. + (should (stringp (process-file "sh" nil nil nil "-c" "kill -2 $$"))) (with-temp-buffer (write-region "foo" nil tmp-name) (should (file-exists-p tmp-name)) -- 2.39.5