summaryrefslogtreecommitdiff
path: root/userland/libc/stdio/fclose.c
diff options
context:
space:
mode:
Diffstat (limited to 'userland/libc/stdio/fclose.c')
-rw-r--r--userland/libc/stdio/fclose.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/userland/libc/stdio/fclose.c b/userland/libc/stdio/fclose.c
index eb92387..5d66830 100644
--- a/userland/libc/stdio/fclose.c
+++ b/userland/libc/stdio/fclose.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/fclose.html
// FIXME: Do some actual error checking.
@@ -8,6 +9,9 @@ int fclose(FILE *stream) {
if (stream->fflush) {
stream->fflush(stream);
}
+ if (stream->has_control_over_the_fd) {
+ close(stream->fd);
+ }
free(stream->cookie);
}
free(stream);