X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=ucw%2Fdaemon.h;h=c5beacc060ca8186171e91fad6a9ef3b3878dffa;hb=f17e4350dcf0c033891e52b30b0c32a4a4fed5e0;hp=c99f8e0849f5f525efbdfe7b632421ed9327edfa;hpb=468db9e951d59f64a479233df5c8c8ccae477d3a;p=libucw.git diff --git a/ucw/daemon.h b/ucw/daemon.h index c99f8e08..c5beacc0 100644 --- a/ucw/daemon.h +++ b/ucw/daemon.h @@ -30,6 +30,7 @@ struct daemon_params { /** Flags passed to the daemon helper. **/ enum daemon_flags { DAEMON_FLAG_PRESERVE_CWD = 1, // Skip chdir("/") + DAEMON_FLAG_SIMULATE = 2, // Simulate daemonization (avoid fork etc.) }; /** @@ -44,6 +45,9 @@ void daemon_init(struct daemon_params *dp); * 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. + * + * When `DAEMON_FLAG_SIMULATE` is set, it justs calls @body. This is useful + * for running of daemons in a debugger. **/ void daemon_run(struct daemon_params *dp, void (*body)(struct daemon_params *dp)); @@ -86,6 +90,8 @@ enum daemon_control_action { * * `DAEMON_STATUS_NOT_RUNNING` if the action failed, because the daemon is not running * * `DAEMON_STATUS_ERROR` if the action failed for some other reason (in this case, * `dc->error_msg` contains a full error message) + * * `DAEMON_STATUS_STALE` if the daemon was in an undefined state (e.g., a stale PID file); + * for `DAEMON_CONTROL_START`, it means success **/ enum daemon_control_status daemon_control(struct daemon_control_params *dc); @@ -95,6 +101,7 @@ enum daemon_control_status { DAEMON_STATUS_ALREADY_DONE = 100, DAEMON_STATUS_NOT_RUNNING = 101, DAEMON_STATUS_ERROR = 102, + DAEMON_STATUS_STALE = 103, }; #endif