[comp.unix.wizards] FIONREAD

cgy@cs.brown.edu (Curtis Yarvin) (03/26/91)

What is the most elegant way of duplicating Sun's FIONREAD ioctl, which
gets the number of bytes readable from a descriptor, on 4.3BSD systems?

Curtis

mwarren@rws1.ma30.bull.com (Mark Warren) (03/27/91)

cgy@cs.brown.edu (Curtis Yarvin) writes:

>What is the most elegant way of duplicating Sun's FIONREAD ioctl, which
>gets the number of bytes readable from a descriptor, on 4.3BSD systems?

FIONREAD is in 4.3 BSD.  Try ioctl.h.
--

 == Mark Warren                      Bull HN Information Systems Inc. ==
 == (508) 294-3171 (FAX 294-3020)    300 Concord Road     MS852A      ==
 == Mark.Warren@bull.com             Billerica, MA 01821              ==

torek@elf.ee.lbl.gov (Chris Torek) (03/27/91)

In article <69819@brunix.UUCP> cgy@cs.brown.edu (Curtis Yarvin) writes:
>What is the most elegant way of duplicating Sun's FIONREAD ioctl, which
>gets the number of bytes readable from a descriptor, on 4.3BSD systems?

The `most elegant' is to avoid it altogether---FIONREAD tends to induce
races---but by far the simplest method of duplicating Sun's FIONREAD
ioctl is to note that Sun *got* it from 4BSD.  All you have to do is
use it.
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)
Berkeley, CA		Domain:	torek@ee.lbl.gov

bruce@heather.pooh.com (Bruce Robertson) (03/27/91)

In article <69819@brunix.UUCP> cgy@cs.brown.edu (Curtis Yarvin) writes:

>   What is the most elegant way of duplicating Sun's FIONREAD ioctl, which
>   gets the number of bytes readable from a descriptor, on 4.3BSD systems?

How about just using it?  4.3BSD implements the FIONREAD ioctl.

--
Bruce Robertson		bruce@pooh.com			Phone: (702) 329-9333
Hundred Acre		1280 Terminal Way, Suite 26	Reno, NV 89502-3243

cgy@cs.brown.edu (Curtis Yarvin) (03/27/91)

In article <11473@dog.ee.lbl.gov> torek@elf.ee.lbl.gov (Chris Torek) writes:
>In article <69819@brunix.UUCP> cgy@cs.brown.edu (Curtis Yarvin) writes:
>>What is the most elegant way of duplicating Sun's FIONREAD ioctl, which
>>gets the number of bytes readable from a descriptor, on 4.3BSD systems?
>
>The `most elegant' is to avoid it altogether---FIONREAD tends to induce races

This is no doubt why Ultrix, at least, buried it deep within the bowels of
the tty(4) page.  Thanks to everyone who replied.

curtis

"I tried living in the real world
 Instead of a shell
 But I was bored before I even began." - The Smiths