From 8aca3246abd4f40476a6f99fce4ee021703a71e7 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 9 Mar 2021 09:14:04 +0000 Subject: Fix [8419c55e2c]: Tclsh read loop does not handle EINTR --- unix/tclUnixChan.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c index fc01616..b49dde7 100644 --- a/unix/tclUnixChan.c +++ b/unix/tclUnixChan.c @@ -253,12 +253,15 @@ FileInputProc( * nonblocking, the read will never block. */ - bytesRead = read(fsPtr->fd, buf, (size_t) toRead); - if (bytesRead > -1) { - return bytesRead; + do { + bytesRead = read(fsPtr->fd, buf, (size_t) toRead); + } while ((bytesRead < 0) && (errno == EINTR)); + + if (bytesRead < 0) { + *errorCodePtr = errno; + return -1; } - *errorCodePtr = errno; - return -1; + return bytesRead; } /* -- cgit v0.12