summaryrefslogtreecommitdiff
path: root/src/stdio/fclose.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdio/fclose.c')
-rw-r--r--src/stdio/fclose.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/stdio/fclose.c b/src/stdio/fclose.c
index f438a9c2..37198fcb 100644
--- a/src/stdio/fclose.c
+++ b/src/stdio/fclose.c
@@ -26,7 +26,7 @@ int fclose(FILE *stream)
SIGNAL_SAFE(0);
flockfile(stream);
- if (fflush(stream) == EOF) {
+ if (stream->operation == OP_OUTPUT && fflush(stream) == EOF) {
/* set errno */
return EOF;
}
@@ -44,6 +44,7 @@ int fclose(FILE *stream)
}
memset(stream, '\0', sizeof(*stream));
+ stream->fd = -1;
/*
RETURN_SUCCESS(0);