]> Pileus Git - ~andy/fetchmail/blob - lock.h
66b2c36fc09a5ae6155d1eb9e8baa51db250b11e
[~andy/fetchmail] / lock.h
1 /** \file lock.h function declarations (API) for lock.c */
2
3 #ifndef FM_LOCK_H
4 #define FM_LOCK_H
5
6 /* from lock.c: concurrency locking */
7
8 /** Set up the global \a lockfile variable (but do not lock yet). */
9 void fm_lock_setup(struct runctl *);
10
11 /** Assert that we already possess a lock. */
12 void fm_lock_assert(void);
13
14 /** Obtain a lock or exit the program with PS_EXCLUDE. This function is
15  * idempotent, that means it can be run even if we already have the
16  * lock. Note that fm_lock_setup() has to be run beforehand; this
17  * function does not check that condition. */
18 void fm_lock_or_die(void);
19
20 /** Release the lock (unlink the lockfile). */
21 void fm_lock_release(void);
22
23 /** Check the state of the lock file. If there is an error opening or
24  * reading the lockfile, exit with PS_EXCLUDE. If a stale lock file
25  * cannot be unlinked, complain, but continue.  \return
26  * -  0 if no lock is set
27  * - >0 if a fetchmail is running, but not in daemon mode
28  * - <0 if a fetchmail is running in daemon mode.
29  */
30 int  fm_lock_state(void);
31
32 /** If atexit(3) is available on the system this software is compiled on,
33  * register an exit handler to dipose of the lock on process exit. */
34 void fm_lock_dispose(void);
35
36 #endif