2022-10-11 21:08:46 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2022-10-12 17:14:49 +02:00
|
|
|
#include <unistd.h>
|
2022-10-11 21:08:46 +02:00
|
|
|
|
|
|
|
extern "C" void initialize_libc()
|
|
|
|
{
|
2022-10-12 17:14:49 +02:00
|
|
|
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.
|
2022-10-12 17:15:57 +02:00
|
|
|
stderr = fopen("/dev/console", "rw");
|
2022-10-11 21:08:46 +02:00
|
|
|
if (!stderr) exit(errno);
|
2022-10-12 17:15:57 +02:00
|
|
|
stdout = fopen("/dev/console", "rw");
|
2022-10-11 21:08:46 +02:00
|
|
|
if (!stdout) exit(errno);
|
2022-10-12 17:15:57 +02:00
|
|
|
clearerr(stderr);
|
|
|
|
clearerr(stdout);
|
2022-10-11 21:08:46 +02:00
|
|
|
}
|