Hi matija, thanks for the comments.

In this case, we're talking about a webserver application in which the logs are split out to separate files on a per-script and per-site basis, and I imagine typical usage would be to tail all logs for a site, for example just after an upgrade, to monitor for new problems that may have arisen.

So for most of those files, I'd expect no output at all - and therefore also no data on which to base predictions about the next time the file may be updated.

However I can imagine another use would be to turn on verbose debugging for all scripts, then run a filtering monitor over the log files until a particular problem shows itself - in that case I can imagine large quantities of data appearing in all the files.

I do need to cope with the files moving from under me, but the best strategy to cope with that is likely to be quite dependent on the strategy for reading from the file. In this case it is also likely to be dependent on the tools doing the moving - it is possible that the files will temporarily be replaced with a pipe, in which case it is important that I don't end up reading from that. In fact that's the main reason I'm wary of simply opening a pipe from tail(1), which otherwise has all the options I need in its GNU incarnation.

I think I shall try next with a simple fstat/sleep loop, and see what that does for performance under light and heavy loads.

Hugo


In reply to Re: Re: nonblocking I/O - testing whether file has more data to read by hv
in thread nonblocking I/O - testing whether file has more data to read by hv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.