comparison common/linuxlockfile.h @ 782:20ca94680003

Implemented detection of running instance on linux using a lock file.
author Sascha Wilde <wilde@intevation.de>
date Mon, 14 Jul 2014 12:46:47 +0200
parents
children 78798d3af8f0
comparison
equal deleted inserted replaced
773:2c69298b4188 782:20ca94680003
1 /**
2 * @file linuxlockfile.h
3 * @brief Linux specific functions for lock file handling.
4 * @details Functions to handle procsss specific lock files, these are
5 * only used on GNU Linux as on windows different mechanisms are
6 * utilized to ensure only a single instance runs at a time.
7 */
8
9 #ifndef LINUXLOCKFILE_H
10 #define LINUXLOCKFILE_H
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 /**
17 * @brief create a lockfile
18 * @details create and lock a lockfile containing the pid of the
19 * current process. fcntl is used for locking, to work in most cases
20 * (e.g. NFS).
21 * @param[in] path to the lockfile
22 * @returns the file descriptor of the lockfile or -1 on error
23 */
24 int open_lockfile(char *path);
25
26 /**
27 * @brief close a lockfile
28 * @details unlock and close a lockfile for the given file descriptor.
29 * @param[in] path to the lockfile
30 * @returns the file descriptor of the lockfile or -1 on error
31 */
32 void close_lockfile(int fd);
33
34 #ifdef __cplusplus
35 }
36 #endif
37
38 #endif

http://wald.intevation.org/projects/trustbridge/