From dee0471914bb2b9d7bba088679f1259dd34b8ff1 Mon Sep 17 00:00:00 2001 From: hobbs Date: Thu, 18 Oct 2001 01:01:15 +0000 Subject: * unix/tclUnixPipe.c (PipeInputProc, PipeOutputProc): do immediate retry when error is returned with errno == EINTR. [Bug #415131] (leger) --- ChangeLog | 6 ++++++ unix/tclUnixPipe.c | 38 +++++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index d1537ad..41264e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-10-17 Jeff Hobbs + + * unix/tclUnixPipe.c (PipeInputProc, PipeOutputProc): do immediate + retry when error is returned with errno == EINTR. + [Bug #415131] (leger) + 2001-10-16 Jeff Hobbs * unix/tclLoadAout.c (TclGuessPackageName): removed unused vars diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index 85316c0..82f180e 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixPipe.c,v 1.15 2001/09/04 18:06:35 vincentdarley Exp $ + * RCS: @(#) $Id: tclUnixPipe.c,v 1.16 2001/10/18 01:01:15 hobbs Exp $ */ #include "tclInt.h" @@ -1003,14 +1003,20 @@ PipeInputProc(instanceData, buf, toRead, errorCodePtr) * appropriately, and read will unblock as soon as a short read is * possible, if the channel is in blocking mode. If the channel is * nonblocking, the read will never block. + * Some OSes can throw an interrupt error, for which we should + * immediately retry. [Bug #415131] */ - bytesRead = read(GetFd(psPtr->inFile), buf, (size_t) toRead); - if (bytesRead > -1) { - return bytesRead; + do { + bytesRead = read (GetFd(psPtr->inFile), buf, (size_t) toRead); + } while ((bytesRead < 0) && (errno == EINTR)); + + if (bytesRead < 0) { + *errorCodePtr = errno; + return -1; + } else { + return bytesRead; } - *errorCodePtr = errno; - return -1; } /* @@ -1043,12 +1049,22 @@ PipeOutputProc(instanceData, buf, toWrite, errorCodePtr) int written; *errorCodePtr = 0; - written = write(GetFd(psPtr->outFile), buf, (size_t) toWrite); - if (written > -1) { - return written; + + /* + * Some OSes can throw an interrupt error, for which we should + * immediately retry. [Bug #415131] + */ + + do { + written = write(GetFd(psPtr->outFile), buf, (size_t) toWrite); + } while ((written < 0) && (errno == EINTR)); + + if (written < 0) { + *errorCodePtr = errno; + return -1; + } else { + return written; } - *errorCodePtr = errno; - return -1; } /* -- cgit v0.12