open_exclusive()

open_exclusive()#

open_exclusive() opens a file with exclusive access, ensuring that no other process can lock it simultaneously.

Prototype

int open_exclusive(
    const char *path,
    int         flags,
    int         permission
);

Parameters

Key

Type

Description

path

const char *

The file path to be opened.

flags

int

Flags for opening the file. If set to 0, default flags (O_RDWR | O_LARGEFILE | O_NOFOLLOW) are used.

permission

int

The file permission mode, used when creating a new file.


Return Value

Returns a file descriptor on success, or -1 on failure.

Notes

This function applies an exclusive lock (LOCK_EX | LOCK_NB) to the file, ensuring that no other process can acquire a lock on it.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples