1 /** \file lock.h function declarations (API) for lock.c */
6 /* from lock.c: concurrency locking */
8 /** Set up the global \a lockfile variable (but do not lock yet). */
9 void fm_lock_setup(struct runctl *);
11 /** Assert that we already possess a lock. */
12 void fm_lock_assert(void);
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);
20 /** Release the lock (unlink the lockfile). */
21 void fm_lock_release(void);
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.
30 int fm_lock_state(void);
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);