YAZ
5.34.0
|
Unix daemon management. More...
Go to the source code of this file.
Macros | |
#define | YAZ_DAEMON_FORK 1 |
#define | YAZ_DAEMON_DEBUG 2 |
#define | YAZ_DAEMON_KEEPALIVE 4 |
#define | YAZ_DAEMON_LOG_REOPEN 8 |
Functions | |
int | yaz_daemon (const char *progname, unsigned int flags, void(*work)(void *data), void *data, const char *pidfile, const char *uid) |
daemon utility. More... | |
void | yaz_daemon_stop (void) |
stop daemon - stop parent process More... | |
Unix daemon management.
Definition in file daemon.h.
int yaz_daemon | ( | const char * | progname, |
unsigned int | flags, | ||
void(*)(void *data) | work, | ||
void * | data, | ||
const char * | pidfile, | ||
const char * | uid | ||
) |
daemon utility.
progname | program name for logging purposes. |
flags | flags which is a bit-wise combination of YAZ_DAEMON_.. |
work | working handler (which may be running in different process) |
data | opaque data to be passed to work handler |
pidfile | filename with Process-ID (NULL for no file) |
uid | effective user ID for handler (NULL for no same as caller) |
This function puts calls work handler which is supposed to carry out a daemon service with a possible changed User ID and in a child process.
Flag YAZ_DAEMON_FORK: Puts the service in the background on Unix.
Flag YAZ_DAEMON_DEBUG: Puts the service in debug mode (no fork at all).
Flag YAZ_DAEMON_KEEPALIVE: Repeatedly calls work handler if it makes a "fatal" error.
Flag YAZ_DAEMON_LOG_REOPEN: Re-opens yaz log if SIGHUP is received
Definition at line 229 of file daemon.c.
References YAZ_DAEMON_DEBUG, YAZ_DAEMON_FORK, YAZ_DAEMON_KEEPALIVE, YAZ_DAEMON_LOG_REOPEN, yaz_log(), yaz_log_file(), YLOG_ERRNO, YLOG_FATAL, and YLOG_WARN.
Referenced by statserv_sc_main().
void yaz_daemon_stop | ( | void | ) |
stop daemon - stop parent process
This function sends a signal to the parent keepalive process that makes it exit immediately - without waiting. If there's no parent keepalive process, this function does nothing. SHould be called when the child process has freed resources, such as listening socket. But the child process may continue running.