in reply to flock and read-ahead buffering on input

I'm not sure I understand your question.

Assuming advisory locking, your exclusive lock is useless unless other processes are also using locking.

If other processes are using locking, then they should obtain at least a shared lock before reading. If they obtain a lock before you attempt an exclusive lock they you won't get your lock. If you get your lock first, then they won't get one.

I assume that by read ahead buffering, you are referring to read ahead by the OS kernel Any writes by your process should invalidate the relevant block buffered in the kernel.

If you are referring buffering in the user space of the other processes via the standard IO library. I don't think this will happen unless the other processes perform a read of the file before trying to get a lock.

If you are dealing with networked file systems. Things become murky.

I'm most familiar with *NIX. If you are running on MS windows then behaviour may differ.

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