X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Flockfile.hpp;fp=src%2Fcommon%2Flockfile.hpp;h=1f8e01ddb3eaaadb59abeaed946d34f0f9332f2c;hp=0000000000000000000000000000000000000000;hb=513792873b851baef066648b41f9cbfe978063fc;hpb=becd029c4fda2dc6478751f4d45fa6b68a1d6120 diff --git a/src/common/lockfile.hpp b/src/common/lockfile.hpp new file mode 100644 index 000000000..1f8e01ddb --- /dev/null +++ b/src/common/lockfile.hpp @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2023 Jérémie Galarneau + * + * SPDX-License-Identifier: LGPL-2.1-only + * + */ + +#ifndef COMMON_LOCKFILE_H +#define COMMON_LOCKFILE_H + +/* + * Create lock file to the given path and filename. + * Returns the associated file descriptor, -1 on error. + * + * Note that on systems that don't support flock, POSIX file locks are used. + * As such, the file lock is dropped whenever any of the file descriptors + * associated to the file's description is closed. + * + * For instance, the lock file is dropped if the process forks+exits or + * forks+execve as the child process closes a file descriptor referencing + * the file description of 'filepath'. + */ +int utils_create_lock_file(const char *filepath); + +#endif /* COMMON_LOCKFILE_H */