GNU bug report logs -
#54062
29.0.50; [PATCH] Eshell should inform processes when a pipe is broken
Previous Next
Reported by: Jim Porter <jporterbugs <at> gmail.com>
Date: Sat, 19 Feb 2022 04:21:01 UTC
Severity: normal
Tags: patch
Found in version 29.0.50
Fixed in version 29.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #37 received at 54062 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 2/21/2022 10:31 AM, Eli Zaretskii wrote:
>> From: Lars Ingebrigtsen <larsi <at> gnus.org>
>> Cc: Jim Porter <jporterbugs <at> gmail.com>, 54062 <at> debbugs.gnu.org
>> Date: Mon, 21 Feb 2022 18:39:16 +0100
>>
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>
>>> Thanks; I have no further comments.
>>
>> So I've pushed the patch series to Emacs 29.
>
> Something's amiss here: the new test fails on MS-Windows because it
> signals an error inside eshell-wait-for-subprocess:
>
> Test esh-proc-test/sigpipe-exits-process backtrace:
> signal(eshell-pipe-broken #<process sh.exe>)
> eshell-output-object-to-target("killed\n" #<process sh.exe>)
> eshell-output-object("killed\n" nil [nil (nil . 0) (nil . 0)])
> #f(compiled-function () #<bytecode 0x1c2b272f8d5f2c5e>)()
> apply(#f(compiled-function () #<bytecode 0x1c2b272f8d5f2c5e>) nil)
> timer-event-handler([t 25107 54636 874750 nil #f(compiled-function (
> sleep-for(0.1)
> sit-for(0.1)
> (while (if all eshell-process-list (eshell-interactive-process-p)) (
> (let ((start (current-time))) (while (if all eshell-process-list (es
> eshell-wait-for-subprocess(t)
>
> Sounds like the shell is already dead/killed when
> eshell-wait-for-subprocess tries to send it a string?
Thanks for merging, and sorry about the bustage. This turned out to be
because `eshell-sentinel' for the "head" process in the pipeline called
`eshell-output-object', but because the tail process was already dead,
it raised `eshell-pipe-broken'. I believe the reason this only
manifested on MS Windows was due to a timing difference between
`delete-process' and `signal-process'; using the `delete-process' path
on GNU/Linux shows the same problem.
Attached is a patch that ignores the `eshell-pipe-broken' error in
`eshell-sentinel'. It's not really an error in that case anyway, since
we only want to write the last bit of output *if we can*.
--------------------
There's just one problem remaining: when running the following command
on MS Windows[1], you'll (usually) see two Eshell prompts get emitted
after it finishes:
yes | sh -c 'read NAME'
However, this is a separate bug that appears in Emacs 27.2 as well. It
can happen whenever multiple commands in a pipeline get killed. For example:
~ $ sh -c 'while true; do sleep 1; echo y; done' | sh -c 'while true;
do read NAME; echo ${NAME}; done'
C-c C-c ; Call `eshell-interrupt-process'
The same happens with C-c C-k (`eshell-kill-process') too. I'll file
another bug about this, but I wanted to mention it here so no one's
surprised if they see this come up when testing out this patch.
[1] Well, I assume it's a problem on MS Windows. I actually tested the
MS Windows code path on GNU/Linux.
[0001-Ignore-eshell-broken-pipe-error-in-eshell-sentinel.patch (text/plain, attachment)]
This bug report was last modified 3 years and 146 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.