[comp.unix.wizards] Number of chars in input queue - terminal, keyboard

jwd@sas.UUCP (John W. DeBoskey) (01/10/90)

Hello,

   The subject almost says it all. I'm running ISC 1.0.6. I want to
find out how many characters are available to read from the terminal
if there are any. ie: avail = in_queue(term_id). 

   A BSD answer is to use FIONREAD, but sVr3 doesn't have it, and I've
been unable to duplicate it. Please don't tell me to RTFM or read
the monthly intros. I have and they don't help. I'm starting to think
the only way I can do this is to actually issue a read, and do my own
internal buffering, but I DON'T really want to do this.

   If anyone has some ideas, or knows a way that isn't doc'd, please
let me know. I'd really appreciate it. Thanks!!

                                      John W De Boskey

jwd@sas.UUCP     (w)  jwd%sas@rti.rti.org
jwd@baggins.UUCP (h)  jwd%baggins@mcnc.mcnc.org

gwyn@smoke.BRL.MIL (Doug Gwyn) (01/10/90)

In article <1439@sas.UUCP> jwd@sas.UUCP (John W. DeBoskey) writes:
>   A BSD answer is to use FIONREAD, but sVr3 doesn't have it, and I've
>been unable to duplicate it.

There really is no even semi-standard way to obtain this information,
and in many UNIX implementations it cannot be obtained at all by
unprivileged processes.

Therefore the question should be asked, why do you think you need
this information?  I have NEVER in many years of UNIX system
programming needed such information, which makes me suspect you
don't really need it either.  If all you want to do is to avoid
blocking on a read from the terminal (the most common motivation
for such queries), other methods will accomplish that.  System V
also provides a way to control input burst size, which may be what
you desire.  Without more information about the application it is
hard to give good advice.

bill@twwells.com (T. William Wells) (01/10/90)

In article <1439@sas.UUCP> jwd@sas.UUCP (John W. DeBoskey) writes:
:    The subject almost says it all. I'm running ISC 1.0.6. I want to
: find out how many characters are available to read from the terminal
: if there are any. ie: avail = in_queue(term_id).

As far as I know, it can't be done without kernel hacking.

---
Bill                    { uunet | novavax | ankh | sunvice } !twwells!bill
bill@twwells.com