X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=include%2Fyaz%2Fdaemon.h;h=34902f94d8add7329e8c81f05759732531873311;hb=bab540a6816b1ae07a834075e0c71d0f160565e4;hp=981327d5b6b6563f3a509421024688f418bbb94c;hpb=906a9c59f8c77f4002616a34b0b98d91d8b1bbc5;p=yaz-moved-to-github.git diff --git a/include/yaz/daemon.h b/include/yaz/daemon.h index 981327d..34902f9 100644 --- a/include/yaz/daemon.h +++ b/include/yaz/daemon.h @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $Id: daemon.h,v 1.1 2008-02-18 17:07:05 adam Exp $ */ +/* $Id: daemon.h,v 1.3 2008-02-21 10:44:43 adam Exp $ */ /** * \file daemon.h @@ -43,6 +43,27 @@ YAZ_BEGIN_CDECL #define YAZ_DAEMON_DEBUG 2 #define YAZ_DAEMON_KEEPALIVE 4 +/** \brief daemon utility. + \param progname program name for logging purposes. + \param flags flags which is a bit-wise combination of YAZ_DAEMON_.. + \param work working handler (which may be running in different process) + \param data opaque data to be passed to work handler + \param pidfile filename with Process-ID (NULL for no file) + \param 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. +*/ +YAZ_EXPORT int yaz_daemon(const char *progname, unsigned int flags, void (*work)(void *data), void *data,