mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-06 17:48:37 +00:00
LibC: Flush all file streams on exit
The POSIX standard specifies the following: > If the main() function returns to its original caller, or if the > exit() function is called, all open files are closed (hence all output > streams are flushed) before program termination. This means that flushing `stdin` and `stdout` only is not enough, as the program might have pending writes in other file buffers too. Now that we support `fflush(nullptr)`, we call that in `exit()` to flush all streams. This fixes one of bash's generated headers not being written to disk.
This commit is contained in:
parent
6a6dbf5b0b
commit
a1dfa1efb2
Notes:
sideshowbarker
2024-07-18 03:23:00 +09:00
Author: https://github.com/BertalanD
Commit: a1dfa1efb2
Pull-request: https://github.com/SerenityOS/serenity/pull/11907
Reviewed-by: https://github.com/Quaker762
Reviewed-by: https://github.com/bgianfo
1 changed files with 1 additions and 2 deletions
|
@ -189,8 +189,7 @@ void exit(int status)
|
||||||
|
|
||||||
extern void _fini();
|
extern void _fini();
|
||||||
_fini();
|
_fini();
|
||||||
fflush(stdout);
|
fflush(nullptr);
|
||||||
fflush(stderr);
|
|
||||||
|
|
||||||
#ifndef _DYNAMIC_LOADER
|
#ifndef _DYNAMIC_LOADER
|
||||||
__pthread_key_destroy_for_current_thread();
|
__pthread_key_destroy_for_current_thread();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue