in reply to Re^2: flock and read-ahead buffering on input
in thread flock and read-ahead buffering on input

Perl won't do any read-ahead buffering of the file until you perform the first read action. If the kernel performs read-ahead, it has a global picture of the file and and all processes, and will be capable of invalidating any buffered data if necessary.

So that code is perfectly safe for your needs.

Dave.

  • Comment on Re^3: flock and read-ahead buffering on input

Replies are listed 'Best First'.
Re^4: flock and read-ahead buffering on input
by dbooth (Novice) on Apr 18, 2014 at 17:46 UTC
    Thanks, that's the key piece of information that I needed. Unfortunately it is not documented in the sysopen, flock or read documentation. Can you point me to where that is documented?
      Thanks, that's the key piece of information that I needed. Unfortunately it is not documented in the sysopen, flock or read documentation. Can you point me to where that is documented?
      Which are you referring to? That perl won't read-ahead, or that the kernel knows what it's doing? For the former, the whole purpose of sysopen/sysread etc is to avoid buffer layers; the man page for sysread specifically states this.

      As for the kernel, this is basic; if the kernel didn't do that it would be broken beyond belief.

      Dave.

        I was looking for evidence that perl won't read-ahead when sysopen is called. The perldoc for sysopen says nothing about buffering one way or another, nor does the perldoc for read. I see now that the perdoc for sysread says that it "bypassess buffered IO", though I hadn't looked there before, since I'm using read -- not sysread.

        Thanks very much for your help!