ioctl
Rob Warnock
rpw3 at rigden.wpd.sgi.com
Wed May 22 19:09:02 AEST 1991
In article <1991May21.224750.535 at murdoch.acc.Virginia.EDU>
acl3k at agate.cs.Virginia.EDU (Allan Christian Long) writes:
+---------------
| an ioctl call is giving me an "Invalid argument error". The
| call looks like this:
|
| if (ioctl(trackerPtr->fileDescriptor, FIONREAD, &charsToRead) < 0)
|
| The first parameter is a file descriptor and the third is a pointer to
| a long. FIONREAD is a parameter from the termio.h file. I have RTFM'ed
| until I'm blue in the face, but I can't find FIONREAD mentioned anywhere
| in any of the manuals. The SunOS manual has a page on "filio" that
| describes this parameter, but there is no filio page for IRIX.
+---------------
In /usr/include/sys/ioctl.h, one finds:
#define FIONREAD _IOR(f, 127, int) /* get # bytes to read */
Sadly, this is about all that exists. The rest does indeed seem to have
fallen between the cracks. (*sigh*) It should be in at least *one* of
ioctl(2), fcntl(2), socket(2), termio(7), or streamio(7), but isn't.
And the comment in ioctl.h is even a bit misleading. Well, the SunOS
filio(2) man page should be good enough. FIONREAD is the same on all
systems I know of -- that support it, that is, not all do. It returns
the number of bytes immediately available for reading (i.e., without
blocking) from the file descriptor. In Irix, it *should* work on plain
files, pipes, sockets, and terminal devices (TTYs and PTYs). What kind
of device is "trackerPtr->fileDescriptor"? If it's a special 3rd-party
beast, perhaps the Irix device driver doesn't support FIONREAD...
-Rob
p.s. I just checked, and on Irix 3.3.2, FIONREAD is not supported on
pipes or plain files. You get errno=25. Weird. (Bug?)
-----
Rob Warnock, MS-1L/515 rpw3 at sgi.com rpw3 at pei.com
Silicon Graphics, Inc. (415)335-1673 Protocol Engines, Inc.
2011 N. Shoreline Blvd.
Mountain View, CA 94039-7311
More information about the Comp.sys.sgi
mailing list