[ale] FW:

Chris Fowler ChrisF at computone.com
Mon Jan 22 09:42:37 EST 2001





I'm using the below code to check the console input buffer which would be STDIN for an `ESC` key press.


Even when it seems there nothing in '0', read returns 1 and prints what it reads.  Which is nothing.  I intend to use this to see if a user has

presed the ESC key on bootup.  This program will be called fomr /etc/rc.d/sysinit but before the loading of the serail driver.  When the serial driver loads, it will flush STDIN.  Am I doing what I want in the proper manner?

Thanks,
Chris


----------- Checkkey.c ----------------
#include <stdio.h>
#include <unistd.h>
#include <termios.h>





void
main(void)
{
        
        char *key='\0';
        struct termios term;
        struct termios oterm;


        tcgetattr(1, &term);
        oterm = term;
        
        term.c_lflag &= ~ICANON;
        term.c_cc[VTIME]=0;     
        term.c_cc[VMIN]=0;      
        tcsetattr(1, TCSANOW, &term);
        if (read(0,key,1));
                printf("Key:%c\n",key);



        tcsetattr(1, TCSANOW, &oterm);
}







More information about the Ale mailing list