--- init.c-orig 2014-02-11 20:31:37.688063205 +0100 +++ init.c 2014-02-11 20:38:45.580073375 +0100 @@ -978,6 +978,8 @@ char *args[16]; /* Argv array */ char buf[136]; /* Line buffer */ int f, st; /* Scratch variables */ + int fdtty1, fdtty2; /* Handlers for TTY controlling dup()*/ + int fdnull1, fdnull2; /* Handlers for /dev/null dup() */ char *ptr; /* Ditto */ time_t t; /* System time */ int oldAlarm; /* Previous alarm value */ @@ -1111,12 +1113,15 @@ if ((ftty = console_open(O_RDWR|O_NOCTTY)) >= 0) { /* Take over controlling tty by force */ (void)ioctl(ftty, TIOCSCTTY, 1); + + fdtty1 = dup(ftty); + fdtty2 = dup(ftty); - if(dup(ftty) < 0){ + if(fdtty1 == -1){ initlog(L_VB, "cannot duplicate console fd"); } - if(dup(ftty) < 0){ + if(fdtty2 == -1){ initlog(L_VB, "cannot duplicate console fd"); } @@ -1189,11 +1194,14 @@ fd = open("/dev/null", O_RDWR); } - if(dup(fd) < 0) { + fdnull1 = dup(fd); + fdnull2 = dup(fd); + + if(fdnull1 == -1) { initlog(L_VB, "cannot duplicate /dev/null fd"); } - if(dup(fd) < 0) { + if(fdnull2 < 0) { initlog(L_VB, "cannot duplicate /dev/null fd"); }