diff --git a/userspace/libraries/LibC/stdio.cpp b/userspace/libraries/LibC/stdio.cpp index a9279040..3e9b506f 100644 --- a/userspace/libraries/LibC/stdio.cpp +++ b/userspace/libraries/LibC/stdio.cpp @@ -404,7 +404,8 @@ FILE* freopen(const char* pathname, const char* mode_str, FILE* file) if (pathname) { - fclose(file); + fflush(file); + close(file->fd); file->fd = open(pathname, mode, 0666); file->mode = mode & O_ACCMODE; if (file->fd == -1)