summaryrefslogtreecommitdiff
path: root/ghc/lib/std/cbits/writeFile.c
diff options
context:
space:
mode:
authorsimonmar <unknown>1999-11-05 15:25:49 +0000
committersimonmar <unknown>1999-11-05 15:25:49 +0000
commit6a8ca29f72bb99475d042e18bce1ad7c0f637ee1 (patch)
tree5e664a4ff220ce02fc09d6821060105ca3717b8b /ghc/lib/std/cbits/writeFile.c
parent46a9ec151e8b78c44f93130eb36d7d325c72a76e (diff)
downloadhaskell-6a8ca29f72bb99475d042e18bce1ad7c0f637ee1.tar.gz
[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.)
Diffstat (limited to 'ghc/lib/std/cbits/writeFile.c')
-rw-r--r--ghc/lib/std/cbits/writeFile.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/ghc/lib/std/cbits/writeFile.c b/ghc/lib/std/cbits/writeFile.c
index 0b459f33b8..0c2f78fd0d 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;