Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site elsie.UUCP Path: utzoo!watmath!clyde!floyd!harpo!seismo!rlgvax!cvl!elsie!mark From: mark@elsie.UUCP Newsgroups: net.unix Subject: Re: non-blocking read Message-ID: <805@elsie.UUCP> Date: Mon, 6-Feb-84 07:02:00 EST Article-I.D.: elsie.805 Posted: Mon Feb 6 07:02:00 1984 Date-Received: Thu, 9-Feb-84 07:11:55 EST References: <964@proper.UUCP> Organization: NIH-LCM, Bethesda, MD Lines: 32 If you have the Berkeley new tty driver you can do the following: #includefoo() { int nchars = 0; for (;;) { ..loop code.. ioctl(0,FIONREAD,(struct sgttyb *) &nchars); if (nchars) { /* Something has been typed at the keyboard */ ..anything else.. } } } The FIONREAD causes the number of chars waiting at the terminal to be placed in nchars. NOTE: if you want to process single chars as they come into the terminal you must be in RAW or CBREAK mode. This is not terribly portable (I try to protect such code with "#ifdef berkeley"'s). I would be interested in knowing if there is a truly portable way of doing this. -- Mark J. Miller NIH/NCI/DCE/LEC UUCP: decvax!harpo!seismo!rlgvax!cvl!elsie!mark Phone: (301) 496-5688