diff options
-rw-r--r-- | src/stdio/putc_unlocked.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/stdio/putc_unlocked.c b/src/stdio/putc_unlocked.c index cf8c9cb4..4a3937e8 100644 --- a/src/stdio/putc_unlocked.c +++ b/src/stdio/putc_unlocked.c @@ -22,10 +22,12 @@ int putc_unlocked(int c, FILE *stream) if (stream->bpos == stream->bsize || (stream->bmode == _IOLBF && ch == '\n') || (stream->bmode == _IONBF)) { - if (write(stream->fd, stream->buf, stream->bpos) != 1) { + if (write(stream->fd, stream->buf, stream->bpos) < 0) { /* errno handled by write() */ + stream->err = 1; return EOF; } + stream->bpos = 0; } return ch; |