--- install2-init.c 2009-10-17 11:05:18.789121846 +0300 +++ _ 2011-01-16 20:30:00.359106091 +0200 @@ -8,6 +8,7 @@ #include #include #include + #include #include #include @@ -130,12 +131,49 @@ break; } + int + linux_kbhit(void) + { + struct termios oldstuff; + struct termios newstuff; + struct timeval tv = {0,1}; /* set one microsecond timeout */ + fd_set rdfds; + int fd = fileno(stdin); /* is usually zero */ + int retval; + + FD_ZERO(&rdfds); + FD_SET(fd, &rdfds); + + tcgetattr(fd, &oldstuff); + newstuff = oldstuff; /* save old attributes */ + + newstuff.c_lflag &= ~(ICANON | ECHO | IGNBRK); + + tcsetattr(fd, TCSANOW, &newstuff); /* set new attributes */ + + if (select(fd + 1, &rdfds, NULL, NULL, &tv) == -1) { + perror("select"); + exit(1); + } + if (FD_ISSET(fd, &rdfds)) { + retval = 1; + } + else { + retval = 0; + } + + tcsetattr(fd, TCSANOW, &oldstuff); /* restore old attributes */ + + return retval; + } + static void countdown(void) { int i; fprintf(stderr, "%s", "\nYou may safely reboot your system\n"); + fprintf(stderr, "%s", "Press any key to reboot\n"); fflush(stderr); /* Set countdown when METHOD = cdrom */ @@ -143,6 +181,9 @@ { for (i = REBOOT_TIMEOUT; i > 0; --i) { + if (linux_kbhit()) + break; + fprintf(stderr, "\rAutomatic reboot after %d seconds... ", i); fflush(stderr); @@ -153,6 +194,8 @@ fflush(stderr); } + + static void killall(void) {