lock_file()
#
The lock_file()
function applies an advisory write lock to the specified file descriptor using the fcntl
system call.
Prototype
int lock_file(int fd);
Parameters
Key |
Type |
Description |
---|---|---|
|
|
The file descriptor of the file to be locked. |
Return Value
Returns 0 on success. On failure, returns -1 and sets errno
to indicate the error.
Notes
This function uses fcntl
with F_SETLKW
to apply a blocking write lock. Ensure that the file descriptor is valid before calling this function.
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples