diff options
Diffstat (limited to 'src/user/lib')
-rw-r--r-- | src/user/lib/file.c | 7 | ||||
-rw-r--r-- | src/user/lib/include/stdio.h | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/user/lib/file.c b/src/user/lib/file.c index bd8cb76..05ae2e8 100644 --- a/src/user/lib/file.c +++ b/src/user/lib/file.c @@ -8,7 +8,10 @@ static FILE _stdin_null = { .fd = 0 }; static FILE _stdout_null = { .fd = 1 }; -FILE *const stdin = &_stdin_null, *const stdout = &_stdout_null; +static FILE _stderr_null = { .fd = 2 }; +FILE *const stdin = &_stdin_null; +FILE *const stdout = &_stdout_null; +FILE *const stderr = &_stderr_null; FILE *fopen(const char *path, const char *mode) { @@ -190,7 +193,7 @@ int fseek(FILE *f, long offset, int whence) { int fclose(FILE *f) { fflush(f); if (f->fd > 0) close(f->fd); - if (f != &_stdin_null && f != &_stdout_null) + if (f != &_stdin_null && f != &_stdout_null && f != &_stderr_null) free(f); return 0; } diff --git a/src/user/lib/include/stdio.h b/src/user/lib/include/stdio.h index fe754da..fd4a676 100644 --- a/src/user/lib/include/stdio.h +++ b/src/user/lib/include/stdio.h @@ -20,7 +20,7 @@ int vsnprintf(char *restrict str, size_t len, const char *restrict fmt, va_list int _klogf(const char *fmt, ...); // for kernel debugging only -extern FILE *const stdin, *const stdout; +extern FILE *const stdin, *const stdout, *const stderr; FILE *fopen(const char *path, const char *mode); FILE *freopen(const char *path, const char *mode, FILE *); |