console.c (327B)
1 #include "console.h" 2 3 #include <fcntl.h> 4 #include <unistd.h> 5 6 // open /dev/console and pipe it stdout/stdin/stderr 7 void init_console() { 8 int in = open("/dev/console", O_RDONLY, 0); 9 int out = open("/dev/console", O_RDWR, 0); 10 dup2(in, 0); 11 dup2(out, 1); 12 dup2(out, 2); 13 14 if (in > 2) 15 close(in); 16 if (out > 2) 17 close(out); 18 }