Querying tty input with ioctl

Ron Natalie ron at topaz.rutgers.edu
Fri Jul 15 11:26:58 AEST 1988


I believe what you are asking is how to detect when there
is TTY input to read.  This can be done with the select
call.  A simplistic example:

    int	    rflags;
    int     ttyfd = 0;	    /*  Standard input, usually 0  */
    struct  timeval tv;

    rflags = 1;		/*  Really 1 << ttyfd, but not sure to be defined */
    tv.sec = 0;		/*  Setting timeout to zero causes select to return  */
    tv.usec =0;		/*  Immediately  */
    select(1, &rflags, (int *) 0,  (int *) 0, &tv);
    if(rflags)  {
	/* There is something to read  */
	read(ttyfd, &c, 1);
    }



More information about the Comp.unix.questions mailing list