name: File Locking API
description: POSIX advisory file locking interfaces for coordinating file access between processes.
image: https://kinlane-productions.s3.amazonaws.com/apis-json/apis-json-logo.jpg
humanURL: https://man7.org/linux/man-pages/man2/fcntl.2.html
baseURL: system://unix/file-locking
tags:
- Advisory-Locking
- Concurrency
- Fcntl
- File-Locking
properties:
- type: Documentation
url: https://man7.org/linux/man-pages/man2/fcntl.2.html
- type: Documentation
url: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html
operations:
- name: fcntl (F_SETLK)
description: Set or release an advisory file lock without blocking
parameters:
- fd
- F_SETLK
- flock
returns: 0 on success, -1 on error
- name: fcntl (F_SETLKW)
description: Set an advisory file lock, blocking if necessary
parameters:
- fd
- F_SETLKW
- flock
returns: 0 on success, -1 on error
- name: fcntl (F_GETLK)
description: Test for the existence of a lock on a file region
parameters:
- fd
- F_GETLK
- flock
returns: 0 on success, -1 on error
- name: flock
description: Apply or remove an advisory lock on an open file
parameters:
- fd
- operation
returns: 0 on success, -1 on error
- name: lockf
description: Apply, test, or remove a POSIX lock on an open file section
parameters:
- fd
- cmd
- len
returns: 0 on success, -1 on error