File.lock

Locks the specified file segment. If the file segment is already locked by another process, waits until the existing lock is released. If both start and length are zero, the entire file is locked.

Locks created using lock and tryLock have the following properties:

  • All locks are automatically released when the process terminates.
  • Locks are not inherited by child processes.
  • Closing a file will release all locks associated with the file. On POSIX, even locks acquired via a different File will be released as well.
  • Not all NFS implementations correctly implement file locking.
struct File
void
lock
(,
ulong start = 0
,
ulong length = 0
)

Meta