From 6a8ca29f72bb99475d042e18bce1ad7c0f637ee1 Mon Sep 17 00:00:00 2001 From: simonmar Date: Fri, 5 Nov 1999 15:25:49 +0000 Subject: [PATCH] [project @ 1999-11-05 15:25:49 by simonmar] Handle potentially blocking writes (yes, I've seen one :) Or rather, its footprint: unfortunately, the error message didn't appear because writes to stderr were returning EAGAIN etc. etc., see accompanying commit to writeError.c.) --- ghc/lib/std/cbits/writeFile.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ghc/lib/std/cbits/writeFile.c b/ghc/lib/std/cbits/writeFile.c index 0b459f3..0c2f78f 100644 --- a/ghc/lib/std/cbits/writeFile.c +++ b/ghc/lib/std/cbits/writeFile.c @@ -1,7 +1,7 @@ /* * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998 * - * $Id: writeFile.c,v 1.8 1999/09/16 13:14:43 simonmar Exp $ + * $Id: writeFile.c,v 1.9 1999/11/05 15:25:49 simonmar Exp $ * * hPutStr Runtime Support */ @@ -62,13 +62,19 @@ StgInt bytes; #else write(fo->fd, pBuf, bytes))) < bytes) { #endif - if (errno != EINTR) { + if ( count == -1 && errno == EAGAIN) { + errno = 0; + return FILEOBJ_BLOCKED_WRITE; + } + else if ( count == -1 && errno != EINTR ) { cvtErrno(); stdErrno(); return -1; } - bytes -= count; - pBuf += count; + else { + bytes -= count; + pBuf += count; + } } /* Signal that we've emptied the buffer */ fo->bufWPtr=0; -- 1.7.10.4