1SD-DAEMON(7)                       sd-daemon                      SD-DAEMON(7)
2
3
4

NAME

6       sd-daemon - Reference implementation of APIs for new-style daemons
7

SYNOPSIS

9       #include "sd-daemon.h"
10

DESCRIPTION

12       sd-daemon.c and sd-daemon.h provide a reference implementation of
13       various APIs for new-style daemons, as implemented by the systemd(1)
14       init system.
15
16       See sd_listen_fds(3), sd_notify(3), sd_booted(3), sd_is_fifo(3) for
17       more information about the functions implemented. In addition to these
18       functions a couple of logging prefixes are defined as macros:
19
20           #define SD_EMERG   "<0>"  /* system is unusable */
21           #define SD_ALERT   "<1>"  /* action must be taken immediately */
22           #define SD_CRIT    "<2>"  /* critical conditions */
23           #define SD_ERR     "<3>"  /* error conditions */
24           #define SD_WARNING "<4>"  /* warning conditions */
25           #define SD_NOTICE  "<5>"  /* normal but significant condition */
26           #define SD_INFO    "<6>"  /* informational */
27           #define SD_DEBUG   "<7>"  /* debug-level messages */
28
29       These prefixes are intended to be used in conjunction with STDERR-based
30       logging as implemented by systemd. If a systemd service definition file
31       is configured with StandardError=syslog or StandardError=kmsg these
32       prefixes can be used to encode a log level in lines printed. This is
33       similar to the kernel printk()-style logging. See klogctl(2) for more
34       information.
35
36       The log levels are identical to syslog(3)´s log level system. To use
37       these prefixes simply prefix every line with one of these strings. A
38       line that is not prefixed will be logged at the default log level
39       SD_INFO.
40
41       Example 1. Hello World
42
43       A daemon may log with the log level NOTICE by issuing this call:
44
45           fprintf(stderr, SD_NOTICE "Hello World!\n");
46

NOTES

48       These interfaces are provided by the reference implementation of APIs
49       for new-style daemons and distributed with the systemd package. The
50       algorithms they implement are simple, and can easily be reimplemented
51       in daemons if it is important to support this interface without using
52       the reference implementation. See the respective function man pages for
53       details.
54
55       In addition, for details about the algorithms check the liberally
56       licensed reference implementation sources:
57       http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.c resp.
58       http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.h
59
60       These APIs are implemented in the reference implementation´s drop-in
61       sd-daemon.c and sd-daemon.h files. It is recommended that applications
62       consuming these APIs copy the implementation into their source tree,
63       either verbatim or in excerpts. These interfaces are currently not
64       available in a dynamic library.
65
66       The functions directly related to new-style daemons become NOPs when
67       -DDISABLE_SYSTEMD is set during compilation. In addition, if
68       sd-daemon.c is compiled on non-Linux systems they become NOPs.
69

SEE ALSO

71       systemd(1), sd_listen_fds(3), sd_notify(3), sd_booted(3),
72       sd_is_fifo(3), daemon(7), systemd.service(5), systemd.socket(5),
73       fprintf(3)
74

AUTHOR

76       Lennart Poettering <lennart@poettering.net>
77           Developer
78
79
80
81systemd                           09/14/2010                      SD-DAEMON(7)
Impressum