summaryrefslogtreecommitdiff
path: root/userland/libc/stdio/fclose.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-11-23 14:59:26 +0100
committerAnton Kling <anton@kling.gg>2024-11-23 16:31:25 +0100
commit934c30d35a3ca0e0bf6cd8709d779e060e27f6d2 (patch)
treeb2d5df8919b7bf721b9901b56cccad3f3d1644e0 /userland/libc/stdio/fclose.c
parent2dce92236b9fe0a9398287ac7c62f2f4e67d53b6 (diff)
libc: Add append to f(d)open and other fixes
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);