kqueue alternative?

Terry Lambert tlambert2 at mindspring.com
Mon Jun 16 22:12:26 PDT 2003


Joshua Oreman wrote:
> > >I would say, use select(2).
> > >Is there a reason this wouldn't work?
> >
> > Select doesn't work with files.
> 
> Really? `man 2 select' says nothing about that. It just talks about
> 'file descriptors'. Now if it said 'socket descriptors' or 'non-file
> file descriptors' I would understand, but I don't think that that statement
> is implied by the man page. Is there something I'm missing?

Select blocks on readfds if a read from the file would block;
that is never the case with a file: you will either get data,
or you will get an EOF.  Select blocks on writefds if a write
to the file would block; that is never the case with a file:
you will either successfully write, or you will get an error,
e.g. as a result of exceeding quota, etc..

Therefore a select for reads or writes on a disk file should
always return true.

-- Terry


More information about the freebsd-hackers mailing list