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 and try to truncate it to 0 size. If
26 * truncation fails, complain and exit with PS_EXCLUDE. \return
27 * - 0 if no lock is set
28 * - >0 if a fetchmail is running, but not in daemon mode
29 * - <0 if a fetchmail is running in daemon mode.
31 int fm_lock_state(void);
33 /** If atexit(3) is available on the system this software is compiled on,
34 * register an exit handler to dipose of the lock on process exit. */
35 void fm_lock_dispose(void);