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.)
/*
* (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
*/
#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;