summaryrefslogtreecommitdiffstats
path: root/include/closestream.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/closestream.h')
-rw-r--r--include/closestream.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/closestream.h b/include/closestream.h
index 2535c8b22..7842456fb 100644
--- a/include/closestream.h
+++ b/include/closestream.h
@@ -24,8 +24,9 @@ close_stream(FILE * stream)
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;
}