[PATCH v2] Fix EINTR handling when reading from a pipe.

Ignacy Gawędzki <[email protected]> Thu, 2 Apr 2026 15:59:03 +0200
Newsgroups org.kernel.vger.dash
Message-ID <4e543oogxlemxnvt7kfbk3s7bugimyiza34kgbq7srofw7qu5i@b6atfz2nfkht>
When using tee to peek at stdin pipe, consider forwarding EINTR
without attempting to read, otherwise pending signals don't get
handled properly.

Signed-off-by: Ignacy Gawędzki <[email protected]>
---
 src/input.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/input.c b/src/input.c
index 71282fb..fd5c36f 100644
--- a/src/input.c
+++ b/src/input.c
@@ -323,11 +323,11 @@ retry:
 
 	if (!fd && !stdin_bufferable()) {
 		nr = stdin_tee(buf, nr);
-		fd = stdin_state.pip[0];
-		if (nr <= 0) {
+		if (nr == 0 || (nr < 0 && errno != EINTR)) {
 			fd = 0;
 			nr = 1;
-		}
+		} else
+			fd = stdin_state.pip[0];
 	}
 
 	if (nr >= 0)
-- 
2.51.0