... the code in close_stdout() is sensitive to EPIPE, so
wipe errno is close_stream() is probably bad idea.
Signed-off-by: Karel Zak <kzak@redhat.com>
const int some_pending = (__fpending(stream) != 0);
const int prev_fail = (ferror(stream) != 0);
const int fclose_fail = (fclose(stream) != 0);
+
if (prev_fail || (fclose_fail && (some_pending || errno != EBADF))) {
- if (!fclose_fail)
+ if (!fclose_fail && !(errno == EPIPE))
errno = 0;
return EOF;
}