From 934c30d35a3ca0e0bf6cd8709d779e060e27f6d2 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Sat, 23 Nov 2024 14:59:26 +0100 Subject: libc: Add append to f(d)open and other fixes --- userland/libc/stdio/fclose.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'userland/libc/stdio/fclose.c') 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 #include +#include // 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); -- cgit v1.2.3