Module Std.Lock_file


module Lock_file: Lock_file

val create : ?message:string -> string -> bool
create ?message path tries to create a file at path containing the text message, which defaults to the pid of the locking process. It returns true on success, false on failure. Note: there is no way to release the lock or the fd created inside! It will only be released when the process dies.

Note the lock file is not cleaned up for you when the process exits. Consider setting up an at_exit handler to unlink the lock-file on program termination.

val create_exn : ?message:string -> string -> unit
create_exn ?message path is like create except that it throws an exception on failure instead of returning a boolean value
val blocking_create : ?message:string -> string -> unit
blocking_create t tries to create the lock. If another process holds the lock this function will wait until it is released.
val is_locked : string -> bool
is_locked path returns true when the file at path exists and is locked, false otherwise.
module Nfs: sig .. end
an implementation neutral NFS lock file scheme that relies on the atomicity of link and rename over NFS (see NFS Illustrated, atomicity for more information).