diff options
Diffstat (limited to 'libio/iofgets.c')
-rw-r--r-- | libio/iofgets.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libio/iofgets.c b/libio/iofgets.c index d61fb81481..98e82782ce 100644 --- a/libio/iofgets.c +++ b/libio/iofgets.c @@ -46,7 +46,10 @@ _IO_fgets (buf, n, fp) old_error = fp->_IO_file_flags & _IO_ERR_SEEN; fp->_IO_file_flags &= ~_IO_ERR_SEEN; count = _IO_getline (fp, buf, n - 1, '\n', 1); - if (count == 0 || (fp->_IO_file_flags & _IO_ERR_SEEN)) + /* If we read in some bytes and errno is EAGAIN, that error will + be reported for next read. */ + if (count == 0 || ((fp->_IO_file_flags & _IO_ERR_SEEN) + && errno != EAGAIN)) result = NULL; else { |