libc: close fds 0 and 1 before opening stdout and stderr
This commit is contained in:
parent
25a460e3c6
commit
dfdc3b2d11
@ -2,9 +2,13 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern "C" void initialize_libc()
|
||||
{
|
||||
close(0); // If it was already open, close it
|
||||
close(1); // If it was already open, close it
|
||||
errno = 0; // If it was not open. the kernel will throw us EBADF. Let's ignore that, since we don't care.
|
||||
__stderr = fopen("/dev/console", "rw");
|
||||
if (!stderr) exit(errno);
|
||||
__stdout = fopen("/dev/console", "rw");
|
||||
|
Loading…
Reference in New Issue
Block a user