This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch/RFC] Fix libstdc++/9533

On Wed, Mar 19, 2003 at 04:04:53PM -0800, Nathan Myers wrote:
> On Wed, Mar 19, 2003 at 11:10:44AM +0100, Paolo Carlini wrote:
> > Nathan Myers wrote:
> > >On Thu, Mar 13, 2003 at 01:54:48PM +0100, Paolo Carlini wrote:
> > >
> > >>the below fixes the problem by implementing a non-trivial showmanyc(),
> > >>as discussed thoroughly on the list during the last weeks.
> > 
> > >First, the above code can only reveal information about sockets, and 
> > >not, unfortunately, pipes.  (On a pipe it reports failure.)  So, the 
> > >comment is not right.  Still, sockets are important enough to merit 
> > >the special treatment.
> We can use 
>   #include <sys/ioctl.h>
>   int i = 0;
>   ::ioctl(fd, FIONREAD, &i)
> on any file descriptor (pipe, socket, file, character device) to see 
> how much is available to read.  
> Note that ioctl is not part of POSIX, and that it is often found at 
> <ioctl.h> instead.  Also, for files bigger than 2G it reports silly
> results...

On many targets it doesn't work on regular files at all.  On some
targets (apparently including FreeBSD and Solarix 9) FIONREAD is 
defined in <sys/filio.h>.  See also

Nathan Myers
ncm-nospam at cantrip dot org

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]