daemon.c File Reference

Unix daemon management. More...

#include <signal.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#include <yaz/daemon.h>
#include <yaz/log.h>
#include <yaz/snprintf.h>

Go to the source code of this file.

Functions

int yaz_daemon (const char *progname, unsigned int flags, void(*work)(void *data), void *data, const char *pidfile, const char *uid)
 daemon utility.


Detailed Description

Unix daemon management.

Definition in file daemon.c.


Function Documentation

int yaz_daemon ( const char *  progname,
unsigned int  flags,
void(*)(void *data)  work,
void *  data,
const char *  pidfile,
const char *  uid 
)

daemon utility.

Parameters:
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)
Returns:
0 for success, non-zero for failure.
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.

Definition at line 160 of file daemon.c.

References YAZ_DAEMON_DEBUG, YAZ_DAEMON_FORK, YAZ_DAEMON_KEEPALIVE, yaz_log(), YLOG_ERRNO, and YLOG_FATAL.


Generated on Mon Dec 29 12:08:46 2008 for YAZ by  doxygen 1.5.6