Subject: bug#66186: "make lisp/eshell/esh-proc-tests" fails intermittently since 7e50861ca7ed3f620fe62ac6572f6e88b3600ece

From: Jim Porter <[email-masked]>
Date: Sun, 24 Sep 2023 22:47:58 -0700

On 9/24/2023 10:34 PM, Jim Porter wrote:
> On 9/24/2023 9:52 PM, Eli Zaretskii wrote:
>> In batch mode, SIGPIPE is not ignored by Emacs, see init_signals.
>> This was changed 11 years ago, see commit 4d7e6e51dd.
> 
> Thanks, I didn't realize that.
> 
>> Perhaps Eshell should check that the process is still alive before
>> calling process-send-string?
> 
> Ok, how about this? Jens, could you try this patch out to see if it 
> fixes things for you?

I forgot to add: Is there potential for a race condition here? I think 
I'd written it the other way because there's a chance that the process 
exits in between checking 'process-live-p' and calling 
'process-send-string'. I guess we could check liveness both before *and* 
after 'process-send-string'. That would probably still leave a small 
chance of the regression tests crashing though, which isn't great.

I could probably also write the test to avoid this race condition 
entirely, since it's not actually trying to trigger a SIGPIPE (though in 
general, Eshell should do the right thing in response to SIGPIPE). That 
would make the regression tests happy.