YANAGAWA Kazuhisa <kjana / os.xaxon.ne.jp> wrote:

> In message <1enk84e.jd9vy8hk39j8N%schuerig / acm.org>
> schuerig / acm.org writes:
> 
> > I'm trying to watch some (log)files for changes. For this purpose,
> > non-blocking I/O and the select function look promising, unfortunately,
> > I don't get them to work.
> 
> You intended `tail -f'?

Close :-)

I want to filter the added lines with regexes and trigger an action if
one matches.

> >         s = f.read();
> 
> Probably here is problem.  How about replacing this `read' with
> `sysread'?

Sounds good, but poses another problem: How to find out the number of
available bytes? If I call sysread with a number exceeding the number of
available bytes, it runs into EOF an throws an exception. Unix read(2)
behaves differently, it only reads at most the number of bytes specified
and returns the actual number read.


> ....Story above is summarized from posts to ruby-list.  Well, that
> threads is on implementing `tail -f' itself.  Hope this help you.

Yes, thanks. I tried to find that thread, but without success. I
wouldn't be able to read it in japanese anyway...


Michael

-- 
Michael Schuerig
mailto:schuerig / acm.org
http://www.schuerig.de/michael/