Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/12/84; site desint.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!sdcsvax!sdcrdcf!trwrb!desint!geoff From: geoff@desint.UUCP (Geoff Kuenning) Newsgroups: net.unix-wizards Subject: Re: Scanning stdin with no pause Message-ID: <279@desint.UUCP> Date: Mon, 24-Dec-84 14:30:23 EST Article-I.D.: desint.279 Posted: Mon Dec 24 14:30:23 1984 Date-Received: Thu, 27-Dec-84 02:41:38 EST References: <6674@brl-tgr.ARPA> <6678@brl-tgr.ARPA> Organization: his home computer, Manhattan Beach, CA Lines: 29 Summary: an even grodier way using timeouts >> I am working with V7 UN*X. I need a way to scan the standard input >> stream for a character, but not wait. > >This is not supported by 7th Edition UNIX. You need to add something >to your kernel to do this directly; the Rand Corp. empty() call has >been distributed by USENIX a long time ago, and more recent approaches >include VTIME,VMIN in AT&T UNIX Systems III & V and select() in 4.2BSD. Also the FIONREAD ioctl found in 4.1BSD and 4.2BSD. If you have access to BSD code, you may be able to copy that one, since it isn't complex code. I prefer the idea of doing it with an ioctl anyway. >A groady way to accomplish this on any UNIX is to use a second process >that communicates with the controlling process via a pipe. An even grodier way is to use a 1-second alarm to blast you off the read if there is nothing coming. This is obviously not much good unless it is the unusual case (e.g., a missed packet in a packet protocol). A final note. If part of your concern is packet protocol efficiency, some people have hacked V7 uucp to do the following: if the last read returned only 1 character, they sleep for some baud-rate-dependent time (calculated to be approximately one packet time) before they issue another read. This markedly improved CPU availability on some V7 systems without affecting uucp performance. -- Geoff Kuenning ...!ihnp4!trwrb!desint!geoff