From 2feac3f3c0a6630aadb4746c3fdcc167bda2e253 Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Sun, 24 Sep 2023 22:30:34 -0700 Subject: [PATCH] ; Adjust Eshell regression tests to avoid SIGPIPE In batch mode, SIGPIPEs can cause Emacs to abort (bug#66186). * lisp/eshell/esh-io.el (eshell-output-object-to-target): Update comment. * test/lisp/eshell/esh-proc-tests.el (esh-proc-test/pipeline-connection-type/middle) (esh-proc-test/pipeline-connection-type/last): Use 'printnl', since that causes no output when called with no arguments, thus avoiding a risky 'process-send-string'. --- lisp/eshell/esh-io.el | 7 +++++-- test/lisp/eshell/esh-proc-tests.el | 20 +++++++------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el index cd0cee6e21d..d0f1e04e925 100644 --- a/lisp/eshell/esh-io.el +++ b/lisp/eshell/esh-io.el @@ -648,8 +648,11 @@ eshell-output-object-to-target (process-send-string target object) (error ;; If `process-send-string' raises an error and the process has - ;; finished, treat it as a broken pipe. Otherwise, just - ;; re-throw the signal. + ;; finished, treat it as a broken pipe. Otherwise, just re-raise + ;; the signal. NOTE: When running Emacs in batch mode + ;; (e.g. during regression tests), Emacs can abort due to SIGPIPE + ;; here. Maybe `process-send-string' should handle SIGPIPE even + ;; in batch mode (bug#66186). (if (process-live-p target) (signal (car err) (cdr err)) (signal 'eshell-pipe-broken (list target))))) diff --git a/test/lisp/eshell/esh-proc-tests.el b/test/lisp/eshell/esh-proc-tests.el index d58764ac29f..2f03c07b35e 100644 --- a/test/lisp/eshell/esh-proc-tests.el +++ b/test/lisp/eshell/esh-proc-tests.el @@ -174,23 +174,17 @@ esh-proc-test/pipeline-connection-type/middle pipeline." (skip-unless (and (executable-find "sh") (executable-find "cat"))) - ;; An `eshell-pipe-broken' signal might occur internally; let Eshell - ;; handle it! - (let ((debug-on-error nil)) - (eshell-command-result-equal - (concat "echo hi | " esh-proc-test--detect-pty-cmd " | cat") - nil))) + (eshell-command-result-equal + (concat "printnl | " esh-proc-test--detect-pty-cmd " | cat") + nil)) (ert-deftest esh-proc-test/pipeline-connection-type/last () "Test that only output streams are PTYs when a command ends a pipeline." (skip-unless (executable-find "sh")) - ;; An `eshell-pipe-broken' signal might occur internally; let Eshell - ;; handle it! - (let ((debug-on-error nil)) - (eshell-command-result-equal - (concat "echo hi | " esh-proc-test--detect-pty-cmd) - (unless (eq system-type 'windows-nt) - "stdout\nstderr\n")))) + (eshell-command-result-equal + (concat "printnl | " esh-proc-test--detect-pty-cmd) + (unless (eq system-type 'windows-nt) + "stdout\nstderr\n"))) ;; Synchronous processes -- 2.25.1