| 1 | /* |
| 2 | * Copyright (C) 2023 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: LGPL-2.1-only |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef COMMON_LOCKFILE_H |
| 9 | #define COMMON_LOCKFILE_H |
| 10 | |
| 11 | /* |
| 12 | * Create lock file to the given path and filename. |
| 13 | * Returns the associated file descriptor, -1 on error. |
| 14 | * |
| 15 | * Note that on systems that don't support flock, POSIX file locks are used. |
| 16 | * As such, the file lock is dropped whenever any of the file descriptors |
| 17 | * associated to the file's description is closed. |
| 18 | * |
| 19 | * For instance, the lock file is dropped if the process forks+exits or |
| 20 | * forks+execve as the child process closes a file descriptor referencing |
| 21 | * the file description of 'filepath'. |
| 22 | */ |
| 23 | int utils_create_lock_file(const char *filepath); |
| 24 | |
| 25 | #endif /* COMMON_LOCKFILE_H */ |