opendevconsole.c (345B) download
1#include "write12.h"
2
3#include <fcntl.h>
4#include <stdlib.h>
5#include <unistd.h>
6
7void opendevconsole() {
8 int fd;
9 if ((fd = open("/dev/console", O_RDWR | O_NOCTTY)) >= 0) {
10 if (dup2(fd, 0) != 0 ||
11 dup2(fd, 1) != 1 ||
12 dup2(fd, 2) != 2) {
13 __write2("dup2 failed unexpectedly.\n");
14 exit(111);
15 }
16 if (fd > 2) close(fd);
17 }
18}