in reply to Re: Fork + Flock = Who Gets the Lock?
in thread Fork + Flock = Who Gets the Lock?

by default, flock doesn't fail when another process already has a lock on the file, it just waits until all the incompatible locks are gone.

To make flock non blocking you have to use the LOCK_NB flag.

  • Comment on Re^2: Fork + Flock = Who Gets the Lock?