lock

Top 

 

Declaration:

int lock(long handle, long offset, long length);

Description

Sets file-sharing locks. lock provides interface to the operating system file-sharing mechanism. The lock can be placed on arbitrary, nonoverlapping regions of any file. A program attempting to read or write into the locked region will retry the operation three times. If all three retries fail, then the call will fail with error.

Returned Value

lock returns 0 on success. On error, lock returns -1 and sets the errno global variable to

EACCES       Locking violation