If you are waiting for some file to change, then some variant of inotify will tell you the file changed without looping continuously in a tail loop burning Mips to not much effect. You can also get notified if a directory changes, some new file appears, perhaps some long awaited "I am finished and ready for business" file.

Update: I suppose also if you opened the file for read, then while(<FILE>)... will cause a program pause in the OS waiting for the next line to appear. You can examine each line waiting for the right msg to be written. Of course this could "deadlock" if the if the other program hangs. But if it dies and file closes, then you should get an EOF. The basic rationale behind these 2 ideas is not burn a lot of Mips waiting for something that itself is burning a lot of Mips where your "watcher" slows things down. I haven't tested, but I don't think you get an EOF if somebody else has the file open for "write". I have used inotify before and that will work.

Update: eatingmyownwords = I now think that that this won't work unless you are using some sort of trick like Tee and reading from a pipe which is left open. I think you get EOF when you reach the current extent of text in the file whether it is open or not for additional writes - that's what tail does.


In reply to Re^2: launch long running background program and watch final progress by Marshall
in thread launch long running background program and watch final progress by mabossert

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.