summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/tramp-adb.el8
-rw-r--r--lisp/net/tramp-sh.el8
-rw-r--r--lisp/net/tramp.el17
-rw-r--r--lisp/simple.el14
4 files changed, 41 insertions, 6 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 7ef07afb8ef..b4a080ee0f6 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -918,9 +918,11 @@ 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))))
+ ;; Handle signals. `process-file-return-signal-string' exists
+ ;; since Emacs 28.1.
+ (when (and (bound-and-true-p process-file-return-signal-string)
+ (natnump ret) (> ret 128))
+ (setq ret (nth (- ret 128) (tramp-get-signal-strings))))
;; 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 c609f58cdd8..523663cafbd 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3159,9 +3159,11 @@ 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))))
+ ;; Handle signals. `process-file-return-signal-string' exists
+ ;; since Emacs 28.1.
+ (when (and (bound-and-true-p process-file-return-signal-string)
+ (natnump ret) (>= ret 128))
+ (setq ret (nth (- ret 128) (tramp-get-signal-strings))))
;; Provide error file.
(when tmpstderr (rename-file tmpstderr (cadr destination) t))
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 70fb46bb4cb..ee263ebe933 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -5047,6 +5047,23 @@ name of a process or buffer, or nil to default to the current buffer."
(lambda ()
(remove-hook 'interrupt-process-functions #'tramp-interrupt-process))))
+(defun tramp-get-signal-strings ()
+ "Strings to return by `process-file' in case of signals."
+ ;; We use key nil for local connection properties.
+ (with-tramp-connection-property nil "signal-strings"
+ (let (result)
+ (if (and (stringp shell-file-name) (executable-find shell-file-name))
+ (dotimes (i 128)
+ (push
+ (if (= i 19) 1 ;; SIGSTOP
+ (call-process
+ shell-file-name nil nil nil "-c" (format "kill -%d $$" i)))
+ result))
+ (dotimes (i 128)
+ (push (format "Signal %d" i) result)))
+ ;; Due to Bug#41287, we cannot add this to the `dotimes' clause.
+ (reverse result))))
+
;; Checklist for `tramp-unload-hook'
;; - Unload all `tramp-*' packages
;; - Reset `file-name-handler-alist'
diff --git a/lisp/simple.el b/lisp/simple.el
index b5ba05426f5..d151d6c9aeb 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4141,6 +4141,20 @@ its behavior with respect to remote file attribute caching.
You should only ever change this variable with a let-binding;
never with `setq'.")
+(defcustom process-file-return-signal-string nil
+ "Whether to return a string describing the signal interrupting a process.
+When a process returns an exit code greater than 128, it is
+interpreted as a signal. `process-file' requires to return a
+string describing this signal.
+Since there are processes violating this rule, returning exit
+codes greater than 128 which are not bound to a signal,
+`process-file' returns the exit code as natural number also in
+this case. Setting this user option to non-nil forces
+`process-file' to interpret such exit codes as signals, and to
+return a corresponding string."
+ :version "28.1"
+ :type 'boolean)
+
(defun start-file-process (name buffer program &rest program-args)
"Start a program in a subprocess. Return the process object for it.