Subject: bug#54062: 29.0.50; [PATCH] Eshell should inform processes when a pipe is broken

From: Jim Porter <[email-masked]>
Date: Tue, 22 Feb 2022 08:49:06 -0800

On 2/22/2022 5:09 AM, Eli Zaretskii wrote:
>> Cc: [email-masked]
>> From: Jim Porter <[email-masked]>
>> Date: Mon, 21 Feb 2022 12:37:59 -0800
>>
>> 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*.
> 
> Thanks, this fixes the test.  However, I'm unsure we should fix this
> inside eshell-sentinel: do we always want to ignore "broken pipe"
> errors in Eshell subprocesses, and never show them to the user?

I think we do want to ignore that error here. In `eshell-sentinel', we 
only run the `finish-io' code when the subprocess's state has already 
changed; in this case, that means the subprocess has already been 
terminated, since Eshell doesn't handle cases like SIGSTOP or SIGCONT 
yet (see the commented out functions at the bottom of 
lisp/eshell/esh-proc.el). Normally, if we detect a broken pipe, we'd 
want to signal the subprocess that tried to write, but since we know 
it's already been terminated, there's no (living) process to signal anymore.

It would be good to support cases like SIGSTOP/SIGCONT in the future, 
but `eshell-sentinel' already fails to account for that, so this patch 
doesn't make things worse in that regard. For example, this function 
always calls `eshell-remove-process-entry', whose docstring says:

   Record the process ENTRY as fully completed.

That's definitely not right for a process being continued with SIGCONT, 
and probably isn't right for SIGSTOP either.