[PATCH] eval: Reset input for pipelines

Herbert Xu <[email protected]>
Newsgroups org.kernel.vger.dash
Message-ID <[email protected]>
On Wed, Jul 24, 2024 at 12:44:39AM -0700, arĉi wrote:
>
> I'm on Arch Linux.
> <details><summary>strace</summary>

Oops, this has nothing to do with the other bug report.  Indeed
I could reproduce this.  The issue is a missing reset_input call
for pipelines.

Thanks,

---8<---
For everything but the first component of a pipeline, the input
needs to be reset because it is no longer equal to that of the
parent shell.

Reported-by: arĉi <[email protected]>
Fixes: b1864ee9f241 ("input: Use lseek on stdin when possible")
Signed-off-by: Herbert Xu <[email protected]>
---
 src/eval.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/eval.c b/src/eval.c
index ad2aa03..0f2a7ba 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -595,6 +595,7 @@ evalpipe(union node *n, int flags)
 				close(pip[0]);
 			}
 			if (prevfd > 0) {
+				reset_input();
 				dup2(prevfd, 0);
 				close(prevfd);
 			}
-- 
2.39.2

-- 
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.