aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2020-05-16 14:04:07 +0200
committerMichael Albinus2020-05-16 14:04:07 +0200
commitbbbab82a7117e08a77433f5ad39b34f5e03a014c (patch)
tree52ce224c6f704873ebbb2c50d9203592c2baea5f
parentdba8f3783b209fef5be2589528ed43a99a8bab6a (diff)
downloademacs-bbbab82a7117e08a77433f5ad39b34f5e03a014c.tar.gz
emacs-bbbab82a7117e08a77433f5ad39b34f5e03a014c.zip
Introduce process-file-return-signal-string
* doc/lispref/processes.texi (Synchronous Processes): Describe `process-file-return-signal-string'. * doc/misc/tramp.texi: Adapt Tramp and Emacs version numbers. (Remote processes): Describe `process-file-return-signal-string' and $INSIDE_EMACS. * etc/NEWS: Describe `process-file-return-signal-string'. Fix typos. * lisp/simple.el (process-file-return-signal-string): New user option. * lisp/net/tramp-adb.el (tramp-adb-handle-process-file): * lisp/net/tramp-sh.el (tramp-sh-handle-process-file): Use it. * lisp/net/tramp.el (tramp-get-signal-strings): New defun. * test/lisp/net/tramp-tests.el (tramp-test28-process-file): Adapt test.
-rw-r--r--doc/lispref/processes.texi16
-rw-r--r--doc/misc/tramp.texi47
-rw-r--r--etc/NEWS97
-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
-rw-r--r--test/lisp/net/tramp-tests.el30
8 files changed, 164 insertions, 73 deletions
diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi
index c6e735a9b1e..22c50936185 100644
--- a/doc/lispref/processes.texi
+++ b/doc/lispref/processes.texi
@@ -477,6 +477,22 @@ You should only ever change this variable with a let-binding; never
477with @code{setq}. 477with @code{setq}.
478@end defvar 478@end defvar
479 479
480@defopt process-file-return-signal-string
481This user option indicates whether a call of @code{process-file}
482returns a string describing the signal interrupting a remote process.
483
484When a process returns an exit code greater than 128, it is
485interpreted as a signal. @code{process-file} requires to return a
486string describing this signal.
487
488Since there are processes violating this rule, returning exit codes
489greater than 128 which are not bound to a signal, @code{process-file}
490returns always the exit code as natural number for remote processes.
491Setting this user option to non-nil forces @code{process-file} to
492interpret such exit codes as signals, and to return a corresponding
493string.
494@end defopt
495
480@defun call-process-region start end program &optional delete destination display &rest args 496@defun call-process-region start end program &optional delete destination display &rest args
481This function sends the text from @var{start} to @var{end} as 497This function sends the text from @var{start} to @var{end} as
482standard input to a process running @var{program}. It deletes the text 498standard input to a process running @var{program}. It deletes the text
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 0b13c17dbcf..d1688deb1b7 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -318,14 +318,14 @@ behind the scenes when you open a file with @value{tramp}.
318@uref{https://ftp.gnu.org/gnu/tramp/}. The version number of 318@uref{https://ftp.gnu.org/gnu/tramp/}. The version number of
319@value{tramp} can be obtained by the variable @code{tramp-version}. 319@value{tramp} can be obtained by the variable @code{tramp-version}.
320For released @value{tramp} versions, this is a three-number string 320For released @value{tramp} versions, this is a three-number string
321like ``2.4.2''. 321like ``2.4.3''.
322 322
323A @value{tramp} release, which is packaged with Emacs, could differ 323A @value{tramp} release, which is packaged with Emacs, could differ
324slightly from the corresponding standalone release. This is because 324slightly from the corresponding standalone release. This is because
325it isn't always possible to synchronize release dates between Emacs 325it isn't always possible to synchronize release dates between Emacs
326and @value{tramp}. Such version numbers have the Emacs version number 326and @value{tramp}. Such version numbers have the Emacs version number
327as suffix, like ``2.3.5.26.3''. This means @w{@value{tramp} 2.3.5} as 327as suffix, like ``2.4.3.27.1''. This means @w{@value{tramp} 2.4.3} as
328integrated in @w{Emacs 26.3}. A complete list of @value{tramp} 328integrated in @w{Emacs 27.1}. A complete list of @value{tramp}
329versions packaged with Emacs can be retrieved by 329versions packaged with Emacs can be retrieved by
330 330
331@vindex customize-package-emacs-version-alist 331@vindex customize-package-emacs-version-alist
@@ -337,12 +337,12 @@ versions packaged with Emacs can be retrieved by
337ELPA} package. Besides the standalone releases, further minor version 337ELPA} package. Besides the standalone releases, further minor version
338of @value{tramp} will appear on GNU ELPA, until the next @value{tramp} 338of @value{tramp} will appear on GNU ELPA, until the next @value{tramp}
339release appears. These minor versions have a four-number string, like 339release appears. These minor versions have a four-number string, like
340``2.4.2.1''. 340``2.4.3.1''.
341 341
342@value{tramp} development versions are available on Git servers. 342@value{tramp} development versions are available on Git servers.
343Development versions contain new and incomplete features. The 343Development versions contain new and incomplete features. The
344development version of @value{tramp} is always the version number of 344development version of @value{tramp} is always the version number of
345the next release, plus the suffix ``-pre'', like ``2.4.3-pre''. 345the next release, plus the suffix ``-pre'', like ``2.4.4-pre''.
346 346
347One way to obtain @value{tramp} from Git server is to visit the 347One way to obtain @value{tramp} from Git server is to visit the
348Savannah project page at the following URL and then clicking on the 348Savannah project page at the following URL and then clicking on the
@@ -2315,7 +2315,7 @@ string of that environment variable looks always like
2315@example 2315@example
2316@group 2316@group
2317echo $INSIDE_EMACS 2317echo $INSIDE_EMACS
2318@result{} 26.2,tramp:2.3.4 2318@result{} 27.1,tramp:2.4.3
2319@end group 2319@end group
2320@end example 2320@end example
2321 2321
@@ -3050,6 +3050,17 @@ host when the variable @code{default-directory} is remote:
3050@end group 3050@end group
3051@end lisp 3051@end lisp
3052 3052
3053@vindex process-file-return-signal-string
3054@code{process-file} shall return either the exit code of the process,
3055or a string describing the signal, when the process has been
3056interrupted. Since it cannot be determined reliably whether a remote
3057process has been interrupted, @code{process-file} returns always the
3058exit code. When the user option
3059@code{process-file-return-signal-string} is non-nil,
3060@code{process-file} regards all exit codes greater than 128 as an
3061indication that the process has been interrupted, and returns a
3062respective string.
3063
3053Remote processes do not apply to @acronym{GVFS} (see @ref{GVFS-based 3064Remote processes do not apply to @acronym{GVFS} (see @ref{GVFS-based
3054methods}) because the remote file system is mounted on the local host 3065methods}) because the remote file system is mounted on the local host
3055and @value{tramp} just accesses by changing the 3066and @value{tramp} just accesses by changing the
@@ -3057,9 +3068,17 @@ and @value{tramp} just accesses by changing the
3057 3068
3058@value{tramp} starts a remote process when a command is executed in a 3069@value{tramp} starts a remote process when a command is executed in a
3059remote file or directory buffer. As of now, these packages have been 3070remote file or directory buffer. As of now, these packages have been
3060integrated to work with @value{tramp}: @file{compile.el} (commands 3071integrated to work with @value{tramp}: @file{shell.el},
3061like @code{compile} and @code{grep}) and @file{gud.el} (@code{gdb} or 3072@file{eshell.el}, @file{compile.el} (commands like @code{compile} and
3062@code{perldb}). 3073@code{grep}) and @file{gud.el} (@code{gdb} or @code{perldb}).
3074
3075@vindex INSIDE_EMACS@r{, environment variable}
3076@value{tramp} always modifies the @env{INSIDE_EMACS} environment
3077variable for remote processes. Per default, this environment variable
3078shows the Emacs version. @value{tramp} adds its own version string,
3079so it looks like @samp{27.1,tramp:2.4.3.1}. However, other packages
3080might also add their name to this environment variable, like
3081@samp{27.1,comint,tramp:2.4.3.1}.
3063 3082
3064For @value{tramp} to find the command on the remote, it must be 3083For @value{tramp} to find the command on the remote, it must be
3065accessible through the default search path as setup by @value{tramp} 3084accessible through the default search path as setup by @value{tramp}
@@ -3254,7 +3273,7 @@ variables.
3254@vindex async-shell-command-width 3273@vindex async-shell-command-width
3255@vindex COLUMNS@r{, environment variable} 3274@vindex COLUMNS@r{, environment variable}
3256If Emacs supports the variable @code{async-shell-command-width} (since 3275If Emacs supports the variable @code{async-shell-command-width} (since
3257@w{Emacs 27.1}), @value{tramp} cares about its value for asynchronous 3276@w{Emacs 27}), @value{tramp} cares about its value for asynchronous
3258shell commands. It specifies the number of display columns for 3277shell commands. It specifies the number of display columns for
3259command output. For synchronous shell commands, a similar effect can 3278command output. For synchronous shell commands, a similar effect can
3260be achieved by adding the environment variable @env{COLUMNS} to 3279be achieved by adding the environment variable @env{COLUMNS} to
@@ -3741,7 +3760,7 @@ row are possible, like @file{/path/to/dir/file.tar.gz.uu/dir/file}.
3741 3760
3742@vindex tramp-archive-all-gvfs-methods 3761@vindex tramp-archive-all-gvfs-methods
3743An archive file name could be a remote file name, as in 3762An archive file name could be a remote file name, as in
3744@file{/ftp:anonymous@@ftp.gnu.org:/gnu/tramp/tramp-2.3.2.tar.gz/INSTALL}. 3763@file{/ftp:anonymous@@ftp.gnu.org:/gnu/tramp/tramp-2.4.3.tar.gz/INSTALL}.
3745Since all file operations are mapped internally to @acronym{GVFS} 3764Since all file operations are mapped internally to @acronym{GVFS}
3746operations, remote file names supported by @code{tramp-gvfs} perform 3765operations, remote file names supported by @code{tramp-gvfs} perform
3747better, because no local copy of the file archive must be downloaded 3766better, because no local copy of the file archive must be downloaded
@@ -3752,7 +3771,7 @@ the similar @samp{/scp:user@@host:...}. See the constant
3752 3771
3753If @code{url-handler-mode} is enabled, archives could be visited via 3772If @code{url-handler-mode} is enabled, archives could be visited via
3754URLs, like 3773URLs, like
3755@file{https://ftp.gnu.org/gnu/tramp/tramp-2.3.2.tar.gz/INSTALL}. This 3774@file{https://ftp.gnu.org/gnu/tramp/tramp-2.4.3.tar.gz/INSTALL}. This
3756allows complex file operations like 3775allows complex file operations like
3757 3776
3758@lisp 3777@lisp
@@ -3760,8 +3779,8 @@ allows complex file operations like
3760(progn 3779(progn
3761 (url-handler-mode 1) 3780 (url-handler-mode 1)
3762 (ediff-directories 3781 (ediff-directories
3763 "https://ftp.gnu.org/gnu/tramp/tramp-2.3.1.tar.gz/tramp-2.3.1" 3782 "https://ftp.gnu.org/gnu/tramp/tramp-2.4.2.tar.gz/tramp-2.4.2"
3764 "https://ftp.gnu.org/gnu/tramp/tramp-2.3.2.tar.gz/tramp-2.3.2" "")) 3783 "https://ftp.gnu.org/gnu/tramp/tramp-2.4.3.tar.gz/tramp-2.4.3" ""))
3765@end group 3784@end group
3766@end lisp 3785@end lisp
3767 3786
diff --git a/etc/NEWS b/etc/NEWS
index b93199f362f..303036ece34 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -101,19 +101,23 @@ horizontal movements now stop at the edge of the board.
101 101
102* Changes in Specialized Modes and Packages in Emacs 28.1 102* Changes in Specialized Modes and Packages in Emacs 28.1
103 103
104** EIEIO: 'oset' and 'oset-default' are declared obsolete 104** EIEIO: 'oset' and 'oset-default' are declared obsolete.
105 105
106** New minor mode 'cl-font-lock-built-in-mode' for `lisp-mode' 106** New minor mode 'cl-font-lock-built-in-mode' for `lisp-mode'.
107The mode provides refined highlighting of built-in functions, types, 107The mode provides refined highlighting of built-in functions, types,
108and variables. 108and variables.
109 109
110** archive-mode 110** Archive mode
111
111*** Can now modify members of 'ar' archives. 112*** Can now modify members of 'ar' archives.
112*** Display of summaries unified between backends
113*** New var 'archive-hidden-columns' and cmd 'archive-hideshow-column'
114These let you control which columns are displayed and which are kept hidden
115 113
116** Emacs-Lisp mode 114*** Display of summaries unified between backends.
115
116*** New user option 'archive-hidden-columns' and command
117'archive-hideshow-column'. These let you control which columns are
118displayed and which are kept hidden.
119
120** Emacs Lisp mode
117 121
118*** The mode-line now indicates whether we're using lexical or dynamic scoping. 122*** The mode-line now indicates whether we're using lexical or dynamic scoping.
119 123
@@ -158,7 +162,7 @@ this user option.
158This file was a compatibility kludge which is no longer needed. 162This file was a compatibility kludge which is no longer needed.
159 163
160--- 164---
161** 'lisp-mode' now uses 'common-lisp-indent-function'. 165** Lisp mode now uses 'common-lisp-indent-function'.
162To revert to the previous behaviour, 166To revert to the previous behaviour,
163'(setq lisp-indent-function 'lisp-indent-function)' from 'lisp-mode-hook'. 167'(setq lisp-indent-function 'lisp-indent-function)' from 'lisp-mode-hook'.
164 168
@@ -184,7 +188,7 @@ their backends.
184** Eshell 188** Eshell
185 189
186--- 190---
187*** Environment variable INSIDE_EMACS is now copied to subprocesses. 191*** Environment variable 'INSIDE_EMACS' is now copied to subprocesses.
188Its value equals the result of evaluating '(format "%s,eshell" emacs-version)'. 192Its value equals the result of evaluating '(format "%s,eshell" emacs-version)'.
189 193
190** Tramp 194** Tramp
@@ -240,7 +244,7 @@ it after GDB quits. A toggle button is also provided under 'Gud --
240GDB-Windows'. 244GDB-Windows'.
241 245
242+++ 246+++
243*** gdb-mi now has a better logic for displaying source buffers 247*** gdb-mi now has a better logic for displaying source buffers.
244Now GDB only uses one source window to display source file by default. 248Now GDB only uses one source window to display source file by default.
245Customize 'gdb-max-source-window-count' to use more than one window. 249Customize 'gdb-max-source-window-count' to use more than one window.
246Control source file display by 'gdb-display-source-buffer-action'. 250Control source file display by 'gdb-display-source-buffer-action'.
@@ -259,11 +263,11 @@ case-insensitive matching of messages when the old behaviour is
259required, but the recommended solution is to use a correctly matching 263required, but the recommended solution is to use a correctly matching
260regexp instead. 264regexp instead.
261 265
262** Hi-Lock 266** Hi Lock mode
263 267
264--- 268---
265*** Matching in 'hi-lock-mode' is case-sensitive when regexp contains 269*** Matching in 'hi-lock-mode' is case-sensitive when regexp contains
266upper case characters and `search-upper-case' is non-nil. 270upper case characters and 'search-upper-case' is non-nil.
267'highlight-phrase' also uses 'search-whitespace-regexp' 271'highlight-phrase' also uses 'search-whitespace-regexp'
268to substitute spaces in regexp search. 272to substitute spaces in regexp search.
269 273
@@ -274,13 +278,13 @@ The new default value is 2000000 (2 megabytes).
274** Texinfo 278** Texinfo
275 279
276--- 280---
277*** New customizable option 'texinfo-texi2dvi-options'. 281*** New user option 'texinfo-texi2dvi-options'.
278This is used when invoking 'texi2dvi' from 'texinfo-tex-buffer'. 282This is used when invoking 'texi2dvi' from 'texinfo-tex-buffer'.
279 283
280** Rmail 284** Rmail
281 285
282--- 286---
283*** New customizable option 'rmail-re-abbrevs'. 287*** New user option 'rmail-re-abbrevs'.
284Its default value matches localized abbreviations of the "reply" 288Its default value matches localized abbreviations of the "reply"
285prefix on the Subject line in various languages. 289prefix on the Subject line in various languages.
286 290
@@ -290,13 +294,13 @@ prefix on the Subject line in various languages.
290These new navigation commands are bound to 'n' and 'p' in 294These new navigation commands are bound to 'n' and 'p' in
291'apropos-mode'. 295'apropos-mode'.
292 296
293** cc-mode 297** CC mode
294 298
295*** Added support for Doxygen documentation style. 299*** Added support for Doxygen documentation style.
296‘doxygen’ is now valid ‘c-doc-comment-style’ which recognises all 300'doxygen' is now a valid 'c-doc-comment-style' which recognises all
297comment styles supported by Doxygen (namely ‘///’, ‘//!’, ‘/** … */’ 301comment styles supported by Doxygen (namely '///', '//!', '/** … */'
298and ‘/*! … */’. ‘gtkdoc’ remains the default for C and C++ modes; to 302and '/*! … */'. 'gtkdoc' remains the default for C and C++ modes; to
299use ‘doxygen’ by default one might evaluate: 303use 'doxygen' by default one might evaluate:
300 304
301 (setq-default c-doc-comment-style 305 (setq-default c-doc-comment-style
302 '((java-mode . javadoc) 306 '((java-mode . javadoc)
@@ -304,17 +308,17 @@ use ‘doxygen’ by default one might evaluate:
304 (c-mode . doxygen) 308 (c-mode . doxygen)
305 (c++-mode . doxygen))) 309 (c++-mode . doxygen)))
306 310
307or use it in a custom ‘c-style’. 311or use it in a custom 'c-style'.
308 312
309*** Added support to line up ‘?’ and ‘:’ of a ternary operator. 313*** Added support to line up '?' and ':' of a ternary operator.
310The new ‘c-lineup-ternary-bodies’ function can be used as a lineup 314The new 'c-lineup-ternary-bodies' function can be used as a lineup
311function to align question mark and colon which are part of a ternary 315function to align question mark and colon which are part of a ternary
312operator (‘?:’). For example: 316operator ('?:'). For example:
313 317
314 return arg % 2 == 0 ? arg / 2 318 return arg % 2 == 0 ? arg / 2
315 : (3 * arg + 1); 319 : (3 * arg + 1);
316 320
317To enable, add it to appropriate entries in ‘c-offsets-alist’, e.g.: 321To enable, add it to appropriate entries in 'c-offsets-alist', e.g.:
318 322
319 (c-set-offset 'arglist-cont '(c-lineup-ternary-bodies 323 (c-set-offset 'arglist-cont '(c-lineup-ternary-bodies
320 c-lineup-gcc-asm-reg)) 324 c-lineup-gcc-asm-reg))
@@ -325,20 +329,21 @@ To enable, add it to appropriate entries in ‘c-offsets-alist’, e.g.:
325 329
326** browse-url 330** browse-url
327 331
328*** Added support for custom URL handlers 332*** Added support for custom URL handlers.
329 333
330There is a new defvar 'browse-url-default-handlers' and a defcustom 334There is a new variable 'browse-url-default-handlers' and a user
331'browse-url-handlers' being alists with (REGEXP-OR-PREDICATE 335option 'browse-url-handlers' being alists with '(REGEXP-OR-PREDICATE
332. FUNCTION) entries allowing to define different browsing FUNCTIONs 336. FUNCTION)' entries allowing to define different browsing FUNCTIONs
333depending on the URL to be browsed. The defvar is for default 337depending on the URL to be browsed. The variable is for default
334handlers provided by Emacs itself or external packages, the defcustom 338handlers provided by Emacs itself or external packages, the user
335is for the user (and allows for overriding the default handlers). 339option is for the user (and allows for overriding the default
340handlers).
336 341
337Formerly, one could do the same by setting 342Formerly, one could do the same by setting
338'browse-url-browser-function' to such an alist. This usage is still 343'browse-url-browser-function' to such an alist. This usage is still
339supported but deprecated. 344supported but deprecated.
340 345
341*** Categorization of browsing functions in internal vs. external 346*** Categorization of browsing functions in internal vs. external.
342 347
343All standard browsing functions such as 'browse-url-firefox', 348All standard browsing functions such as 'browse-url-firefox',
344'browse-url-mail', or 'eww' have been categorized into internal (URL 349'browse-url-mail', or 'eww' have been categorized into internal (URL
@@ -351,10 +356,11 @@ either an internal or external browser.
351 356
352* New Modes and Packages in Emacs 28.1 357* New Modes and Packages in Emacs 28.1
353 358
354*** Lisp Data mode 359** Lisp Data mode
360
355The new command 'lisp-data-mode' enables a major mode for buffers 361The new command 'lisp-data-mode' enables a major mode for buffers
356composed of Lisp symbolic expressions that do not form a computer 362composed of Lisp symbolic expressions that do not form a computer
357program. The '.dir-locals.el' file is automatically set to use this 363program. The ".dir-locals.el" file is automatically set to use this
358mode, as are other data files produced by Emacs. 364mode, as are other data files produced by Emacs.
359 365
360 366
@@ -436,23 +442,28 @@ such as "2020-01-15T16:12:21-08:00".
436** The new function 'dom-remove-attribute' has been added. 442** The new function 'dom-remove-attribute' has been added.
437 443
438--- 444---
439** 'make-network-process', 'make-serial-process' :coding behavior change. 445** 'make-network-process', 'make-serial-process' ':coding' behavior change.
440Previously, passing ":coding nil" to either of these functions would 446Previously, passing ':coding nil' to either of these functions would
441override any non-nil binding for 'coding-system-for-read' and 447override any non-nil binding for 'coding-system-for-read' and
442'coding-system-for-write'. For consistency with 'make-process' and 448'coding-system-for-write'. For consistency with 'make-process' and
443'make-pipe-process', passing ":coding nil" is now ignored. No code in 449'make-pipe-process', passing ':coding nil' is now ignored. No code in
444Emacs depended on the previous behavior; if you really want the 450Emacs depended on the previous behavior; if you really want the
445process' coding-system to be nil, use 'set-process-coding-system' 451process' coding-system to be nil, use 'set-process-coding-system'
446after the process has been created, or pass in ":coding '(nil nil)". 452after the process has been created, or pass in ':coding '(nil nil)'.
447 453
448+++ 454+++
449** 'open-network-stream' now accepts a :coding argument. 455** 'open-network-stream' now accepts a ':coding' argument.
450This allows specifying the coding systems used by a network process 456This allows specifying the coding systems used by a network process
451for encoding and decoding without having to bind 457for encoding and decoding without having to bind
452coding-system-for-{read,write} or call 'set-process-coding-system'. 458'coding-system-for-{read,write}' or call 'set-process-coding-system'.
459
460+++
461** 'open-gnutls-stream' now also accepts a ':coding' argument.
453 462
454+++ 463+++
455** 'open-gnutls-stream' now also accepts a :coding argument. 464** New user option 'process-file-return-signal-string'.
465It controls, whether 'process-file' returns a string when a remote
466process is interrupted by a signal.
456 467
457 468
458* Changes in Emacs 28.1 on Non-Free Operating Systems 469* Changes in Emacs 28.1 on Non-Free Operating Systems
@@ -473,12 +484,12 @@ current IME activation status.
473** On MS-Windows, Emacs can now use the native image API to display images. 484** On MS-Windows, Emacs can now use the native image API to display images.
474Emacs can now use the MS-Windows GDI+ library to load and display 485Emacs can now use the MS-Windows GDI+ library to load and display
475images in JPEG, PNG, GIF and TIFF formats. This support is enabled 486images in JPEG, PNG, GIF and TIFF formats. This support is enabled
476unless Emacs was configured --without-native-image-api. 487unless Emacs was configured '--without-native-image-api'.
477 488
478This feature is experimental, and needs to be turned on to be used. 489This feature is experimental, and needs to be turned on to be used.
479To turn this on, set the variable 'w32-use-native-image-API' to a 490To turn this on, set the variable 'w32-use-native-image-API' to a
480non-nil value. Please report any bugs you find while using the native 491non-nil value. Please report any bugs you find while using the native
481image API via "M-x report-emacs-bug". 492image API via 'M-x report-emacs-bug'.
482 493
483 494
484---------------------------------------------------------------------- 495----------------------------------------------------------------------
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."
918 (kill-buffer (tramp-get-connection-buffer v)) 918 (kill-buffer (tramp-get-connection-buffer v))
919 (setq ret 1))) 919 (setq ret 1)))
920 920
921 ;; Handle signals. 921 ;; Handle signals. `process-file-return-signal-string' exists
922 (when (and (natnump ret) (> ret 128)) 922 ;; since Emacs 28.1.
923 (setq ret (format "Signal %d" (- ret 128)))) 923 (when (and (bound-and-true-p process-file-return-signal-string)
924 (natnump ret) (> ret 128))
925 (setq ret (nth (- ret 128) (tramp-get-signal-strings))))
924 926
925 ;; Provide error file. 927 ;; Provide error file.
926 (when tmpstderr (rename-file tmpstderr (cadr destination) t)) 928 (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."
3159 (kill-buffer (tramp-get-connection-buffer v)) 3159 (kill-buffer (tramp-get-connection-buffer v))
3160 (setq ret 1))) 3160 (setq ret 1)))
3161 3161
3162 ;; Handle signals. 3162 ;; Handle signals. `process-file-return-signal-string' exists
3163 (when (and (natnump ret) (> ret 128)) 3163 ;; since Emacs 28.1.
3164 (setq ret (format "Signal %d" (- ret 128)))) 3164 (when (and (bound-and-true-p process-file-return-signal-string)
3165 (natnump ret) (>= ret 128))
3166 (setq ret (nth (- ret 128) (tramp-get-signal-strings))))
3165 3167
3166 ;; Provide error file. 3168 ;; Provide error file.
3167 (when tmpstderr (rename-file tmpstderr (cadr destination) t)) 3169 (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."
5047 (lambda () 5047 (lambda ()
5048 (remove-hook 'interrupt-process-functions #'tramp-interrupt-process)))) 5048 (remove-hook 'interrupt-process-functions #'tramp-interrupt-process))))
5049 5049
5050(defun tramp-get-signal-strings ()
5051 "Strings to return by `process-file' in case of signals."
5052 ;; We use key nil for local connection properties.
5053 (with-tramp-connection-property nil "signal-strings"
5054 (let (result)
5055 (if (and (stringp shell-file-name) (executable-find shell-file-name))
5056 (dotimes (i 128)
5057 (push
5058 (if (= i 19) 1 ;; SIGSTOP
5059 (call-process
5060 shell-file-name nil nil nil "-c" (format "kill -%d $$" i)))
5061 result))
5062 (dotimes (i 128)
5063 (push (format "Signal %d" i) result)))
5064 ;; Due to Bug#41287, we cannot add this to the `dotimes' clause.
5065 (reverse result))))
5066
5050;; Checklist for `tramp-unload-hook' 5067;; Checklist for `tramp-unload-hook'
5051;; - Unload all `tramp-*' packages 5068;; - Unload all `tramp-*' packages
5052;; - Reset `file-name-handler-alist' 5069;; - 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.
4141You should only ever change this variable with a let-binding; 4141You should only ever change this variable with a let-binding;
4142never with `setq'.") 4142never with `setq'.")
4143 4143
4144(defcustom process-file-return-signal-string nil
4145 "Whether to return a string describing the signal interrupting a process.
4146When a process returns an exit code greater than 128, it is
4147interpreted as a signal. `process-file' requires to return a
4148string describing this signal.
4149Since there are processes violating this rule, returning exit
4150codes greater than 128 which are not bound to a signal,
4151`process-file' returns the exit code as natural number also in
4152this case. Setting this user option to non-nil forces
4153`process-file' to interpret such exit codes as signals, and to
4154return a corresponding string."
4155 :version "28.1"
4156 :type 'boolean)
4157
4144(defun start-file-process (name buffer program &rest program-args) 4158(defun start-file-process (name buffer program &rest program-args)
4145 "Start a program in a subprocess. Return the process object for it. 4159 "Start a program in a subprocess. Return the process object for it.
4146 4160
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index de85f83982c..1f56baad7ce 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -75,6 +75,7 @@
75;; Needed for Emacs 26. 75;; Needed for Emacs 26.
76(defvar async-shell-command-width) 76(defvar async-shell-command-width)
77;; Needed for Emacs 27. 77;; Needed for Emacs 27.
78(defvar process-file-return-signal-string)
78(defvar shell-command-dont-erase-buffer) 79(defvar shell-command-dont-erase-buffer)
79 80
80;; Beautify batch mode. 81;; Beautify batch mode.
@@ -4208,18 +4209,27 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4208 (should (zerop (process-file "true"))) 4209 (should (zerop (process-file "true")))
4209 (should-not (zerop (process-file "false"))) 4210 (should-not (zerop (process-file "false")))
4210 (should-not (zerop (process-file "binary-does-not-exist"))) 4211 (should-not (zerop (process-file "binary-does-not-exist")))
4211 (should 4212 ;; Return exit code.
4212 (= 42 4213 (should (= 42 (process-file
4214 (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh")
4215 nil nil nil "-c" "exit 42")))
4216 ;; Return exit code in case the process is interrupted,
4217 ;; and there's no indication for a signal describing string.
4218 (let (process-file-return-signal-string)
4219 (should
4220 (= (+ 128 2)
4221 (process-file
4222 (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh")
4223 nil nil nil "-c" "kill -2 $$"))))
4224 ;; Return string in case the process is interrupted and
4225 ;; there's an indication for a signal describing string.
4226 (let ((process-file-return-signal-string t))
4227 (should
4228 (string-equal
4229 "Interrupt"
4213 (process-file 4230 (process-file
4214 (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh") 4231 (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh")
4215 nil nil nil "-c" "exit 42"))) 4232 nil nil nil "-c" "kill -2 $$"))))
4216 ;; Return string in case the process is interrupted.
4217 (should
4218 (string-equal
4219 "Signal 2"
4220 (process-file
4221 (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh")
4222 nil nil nil "-c" "kill -2 $$")))
4223 4233
4224 (with-temp-buffer 4234 (with-temp-buffer
4225 (write-region "foo" nil tmp-name) 4235 (write-region "foo" nil tmp-name)