From: Martin Mares Date: Thu, 12 Jul 2012 16:44:57 +0000 (+0200) Subject: Daemon: Preliminary documentation X-Git-Tag: v5.99~159 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=eec6d2c37cbcbf9c350aa4ca80e5a316e5144087;p=libucw.git Daemon: Preliminary documentation --- diff --git a/ucw/daemon.h b/ucw/daemon.h index 13f8c37a..c00f00d1 100644 --- a/ucw/daemon.h +++ b/ucw/daemon.h @@ -30,10 +30,24 @@ enum daemon_flags { DAEMON_FLAG_PRESERVE_CWD = 1, // Skip chdir("/") }; +/** + * Daemon initialization. Should be run after parsing of options. + * It resolves the UID and GID to run with and locks the PID file. + * Upon error, it calls @die(). + **/ void daemon_init(struct daemon_params *dp); +/** + * Run the daemon. Should be run when everything is initialized. It forks off + * a new process and does all necessary setup. Inside the new process, it calls + * @body (and when it returns, it exits the process). In the original process, it writes + * the PID file and returns. + **/ void daemon_run(struct daemon_params *dp, void (*body)(struct daemon_params *dp)); +/** + * Clean up when the daemon is about to exit. It removes the PID file. + **/ void daemon_exit(struct daemon_params *dp); #endif diff --git a/ucw/doc/Makefile b/ucw/doc/Makefile index c386f4a0..92561d50 100644 --- a/ucw/doc/Makefile +++ b/ucw/doc/Makefile @@ -2,7 +2,7 @@ DIRS+=ucw/doc -UCW_DOCS=basics log fastbuf index config configure install basecode hash docsys conf mempool eltpool mainloop generic growbuf unaligned lists chartype unicode prime binsearch heap binheap compress sort hashtable relnotes trans string time +UCW_DOCS=basics log fastbuf index config configure install basecode hash docsys conf mempool eltpool mainloop generic growbuf unaligned lists chartype unicode prime binsearch heap binheap compress sort hashtable relnotes trans string time daemon UCW_INDEX=$(o)/ucw/doc/def_index.html UCW_DOCS_HTML=$(addprefix $(o)/ucw/doc/,$(addsuffix .html,$(UCW_DOCS))) diff --git a/ucw/doc/daemon.txt b/ucw/doc/daemon.txt new file mode 100644 index 00000000..a5a23dc4 --- /dev/null +++ b/ucw/doc/daemon.txt @@ -0,0 +1,6 @@ +Daemonization helper +==================== + +FIXME: Add general description + +!!ucw/daemon.h