diff options
author | dzwdz | 2022-07-30 14:52:22 +0200 |
---|---|---|
committer | dzwdz | 2022-07-30 14:52:22 +0200 |
commit | b26399ad055aae9ef4b01694967515235568cd85 (patch) | |
tree | f8eec54655b5461e00596d7aa1f2a27aa5fede25 /src/user/lib | |
parent | 9efd7f96b028a69b1da0cf53f6d7be71048c73d7 (diff) |
user: stderr
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 *); |