minit

A small yet feature-complete init (http://fefe.de/minit/)
Log | Files | Refs | README | LICENSE

opendevconsole.c (337B)


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