Lely core libraries  2.3.4
daemon.h
Go to the documentation of this file.
1 
22 #ifndef LELY_UTIL_DAEMON_H_
23 #define LELY_UTIL_DAEMON_H_
24 
25 #include <lely/util/util.h>
26 
27 enum {
46 // clang-format off
48 #if _WIN32
50 #else
51  DAEMON_USER_MAX = 255
52 #endif
53  // clang-format on
54 };
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
68 typedef void daemon_handler_t(int sig, void *handle);
69 
97 int daemon_start(const char *name, int (*init)(int, char **),
98  void (*main)(void), void (*fini)(void), int argc, char *argv[]);
99 
108 int daemon_stop(void);
109 
118 int daemon_pause(void);
119 
129 int daemon_continue(void);
130 
139 int daemon_reload(void);
140 
146 int daemon_signal(int sig);
147 
154 int daemon_status(int status);
155 
166 void daemon_get_handler(daemon_handler_t **phandler, void **phandle);
167 
175 void daemon_set_handler(daemon_handler_t *handler, void *handle);
176 
178 void default_daemon_handler(int sig, void *handle);
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif // !LELY_UTIL_DAEMON_H_
void daemon_handler_t(int sig, void *handle)
The function type of a handler for daemon_signal().
Definition: daemon.h:68
int daemon_stop(void)
Sends the stop signal to the daemon handler.
Definition: daemon.c:578
int daemon_pause(void)
Sends the pause signal to the daemon handler.
Definition: daemon.c:590
void default_daemon_handler(int sig, void *handle)
The default daemon_signal() handler.
Definition: daemon.c:618
int daemon_signal(int sig)
Sends a signal to a daemon, triggering the execution of the daemon handler.
Definition: daemon.c:402
void daemon_get_handler(daemon_handler_t **phandler, void **phandle)
Retrieves current daemon handler and handle argument.
Definition: daemon.c:602
@ DAEMON_START
The status indicating the daemon has started.
Definition: daemon.h:29
@ DAEMON_CONTINUE
The signal/status indicating the daemon SHOULD continue/has continued normal operation.
Definition: daemon.h:41
@ DAEMON_RELOAD
The signal indicating the daemon SHOULD reload its configuration.
Definition: daemon.h:43
@ DAEMON_USER_MAX
The largest possible value of a user-defined signal.
Definition: daemon.h:51
@ DAEMON_PAUSE
The signal/status indicating the daemon SHOULD pause/has paused.
Definition: daemon.h:36
@ DAEMON_STOP
The signal/status indicating the daemon MUST terminate/has terminated.
Definition: daemon.h:34
@ DAEMON_USER_MIN
The smallest possible value of a user-defined signal.
Definition: daemon.h:45
int daemon_reload(void)
Sends the reload signal to the daemon handler.
Definition: daemon.c:584
void daemon_set_handler(daemon_handler_t *handler, void *handle)
Sets the current daemon handler and its (optional) handle argument.
Definition: daemon.c:611
int daemon_continue(void)
Sends the continue signal to the daemon handler.
Definition: daemon.c:596
int daemon_start(const char *name, int(*init)(int, char **), void(*main)(void), void(*fini)(void), int argc, char *argv[])
Executes the supplied function as a POSIX daemon or Windows service.
Definition: daemon.c:251
int daemon_status(int status)
Sets the current daemon status (one of DAEMON_START, DAEMON_STOP, DAEMON_PAUSE or DAEMON_CONTINUE).
Definition: daemon.c:417
This is the public header file of the utilities library.