Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!caen!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!pacbell.com!mips!sgi!rpw3@rigden.wpd.sgi.com From: rpw3@rigden.wpd.sgi.com (Rob Warnock) Newsgroups: comp.sys.sgi Subject: Re: ioctl Message-ID: <105553@sgi.sgi.com> Date: 22 May 91 09:09:02 GMT References: <1991May21.224750.535@murdoch.acc.Virginia.EDU> Sender: news@sgi.sgi.com Reply-To: rpw3@sgi.com (Rob Warnock) Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 43 In article <1991May21.224750.535@murdoch.acc.Virginia.EDU> acl3k@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@sgi.com rpw3@pei.com Silicon Graphics, Inc. (415)335-1673 Protocol Engines, Inc. 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311