Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Jun 2003 21:50:24 -0400 (EDT)
From:      "Matthew Hagerty" <matthew@mundomateo.com>
To:        freebsd-hackers@freebsd.org
Subject:   Re: kqueue alternative?
Message-ID:  <1183.10.0.81.10.1055728224.squirrel@www.mundomateo.com>
In-Reply-To: <3EECB43F.8010609@math.missouri.edu>
References:   <1079.10.0.81.10.1055692530.squirrel@www.mundomateo.com><Pine.NEB.3.96 L.1030615125423.98988D-100000@fledge.watson.org><20030615172902.GB4882 @webserver.get-linux.org> <3EECB43F.8010609@math.missouri.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
> Joshua Oreman wrote:
>> On Sun, 15 Jun 2003, Matthew Hagerty wrote:
>>
>>>I'm writing a little application that needs to watch a file that another
>>>process is writing to, think 'tail -F'.  kqueue and kevent are going to
>>>do it for me on *BSD, but I'm also trying to support *cough* linux and
>>>other UN*X types OSes.
>>>
>>>>From what I can find on google, the linux community seems very opposed
>>>to kqueue and has not yet implemented it (they say: blah blah blah,
>>>aio_*, blah blah balh.)  What alternatives do I have with OSes that
>>>don't support kqueue?  I'd really hate to poll with stat(), but do I
>>>have any other choices?
>>
>>
>> I would say, use select(2).
>> Is there a reason this wouldn't work?
>>
>> -- Josh
>
>
> Either select(2) or poll(2) should work.
>
>
>
> --
> Stephen Montgomery-Smith
> stephen@math.missouri.edu
> http://www.math.missouri.edu/~stephen
>

Last time I did a test, it seemed that I could not read to the end of a
file that another process was writing to, without calling stat() to get
the real size?

So, I open the file for reading, and read/process the data until EOF, at
which point I... ?  call select()?  What should I be watching for if
another process is doing the writing?  Will my select() return if I'm
watching for a ready to read condition while another process is writing?

While writing this response I'm thinking of a function I didn't know about
that I saw in forward.c (part of the tail command's code), clearerr().  If
I hit EOF, and another process writes to the file, will calling clearerr()
on my file pointer allow me to continue reading the new data that was just
written by the other process?  Am I making sense?

Thanks for the insight!

Matthew



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1183.10.0.81.10.1055728224.squirrel>