GNU bug report logs - #79079
31.0.50; Piped command output is sometimes lost in Eshell

Previous Next

Package: emacs;

Reported by: Daniel Mendler <mail <at> daniel-mendler.de>

Date: Wed, 23 Jul 2025 09:57:01 UTC

Severity: normal

Found in version 31.0.50

Full log


View this message in rfc822 format

From: Jim Porter <jporterbugs <at> gmail.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>, Eli Zaretskii <eliz <at> gnu.org>
Cc: mail <at> daniel-mendler.de, 79079 <at> debbugs.gnu.org
Subject: bug#79079: 31.0.50; Piped command output is sometimes lost in Eshell
Date: Sun, 27 Jul 2025 12:34:10 -0700
On 7/27/2025 12:14 PM, Paul Eggert wrote:
> From Jim's recent email it sounds like Eshell does not actually set up 
> a pipe when implementing "A | B", but instead does something else that 
> simulates a pipe. I don't know how the simulation works, but it sounds 
> like the simulated pipe cannot act like a real pipe when B closes its 
> end of the simulated pipe, A ignores SIGPIPE, and A writes to the 
> simulated pipe. With a real pipe A would get an EPIPE error, and I guess 
> that's not happening with the simulated pipe.

If we're being technical, Eshell does use pipes for its pipe operator, 
but there's an additional layer of indirection that makes it difficult 
to simulate the usual POSIX shell piping:

  process A -> stdout pipe -> process filter -> process-send-string -> 
stdin pipe -> process B

If 'process-send-string' fails, we raise a Lisp signal 
'eshell-pipe-broken', that tries to be as much like SIGPIPE as we can. 
Because of this indirection though, process A won't see an EPIPE/SIGPIPE 
at the normally-expected time, hence my comment in esh-proc.el:

           ;; The output pipe broke, so send SIGPIPE to the
           ;; process.  NOTE: Due to the additional indirection
           ;; of Emacs process filters, the process will likely
           ;; see the SIGPIPE later than it would in a regular
           ;; shell, which could cause problems.  For cases
           ;; where this matters, using an external pipe
           ;; operator (`*|') may work instead.

Luckily, this bug is really about what happens with process B in the 
pipeline, so I won't have to make any further changes to the process A 
side of things (at least not yet).




This bug report was last modified 32 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.