summaryrefslogtreecommitdiff
path: root/userland
diff options
context:
space:
mode:
Diffstat (limited to 'userland')
-rw-r--r--userland/libc/stdio/fflush.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/userland/libc/stdio/fflush.c b/userland/libc/stdio/fflush.c
index 3042efa..1cadc72 100644
--- a/userland/libc/stdio/fflush.c
+++ b/userland/libc/stdio/fflush.c
@@ -1,8 +1,15 @@
#include <stdio.h>
+#include <syscall.h>
+#include <errno.h>
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/fflush.html
int fflush(FILE *stream) {
- if (stream->fflush)
- stream->fflush(stream);
- return 0;
+ if (stream) {
+ if (stream->fflush) {
+ stream->fflush(stream);
+ return 0;
+ }
+ }
+ errno = ENXIO;
+ return -1;
}