X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Flockfile.h;fp=src%2Fcommon%2Flockfile.h;h=1f8e01ddb3eaaadb59abeaed946d34f0f9332f2c;hb=cf7e5f0026e05a5044d079f5fcc6264df29828fd;hp=0000000000000000000000000000000000000000;hpb=c03a0ff462df61b6d38fb112aa846356d4aa6c0f;p=lttng-tools.git diff --git a/src/common/lockfile.h b/src/common/lockfile.h new file mode 100644 index 000000000..1f8e01ddb --- /dev/null +++ b/src/common/lockfile.h @@ -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 */