Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!husc6!uwvax!rutgers!topaz.rutgers.edu!ron
From: ron@topaz.rutgers.edu (Ron Natalie)
Newsgroups: comp.unix.questions
Subject: Re: Querying tty input with ioctl
Keywords: ioctl I/O device driver
Message-ID: 
Date: 15 Jul 88 01:26:58 GMT
References: <11527@steinmetz.ge.com>
Distribution: na
Organization: Rutgers Univ., New Brunswick, N.J.
Lines: 15

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);
    }