]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd-daemon.xml
relicense to LGPLv2.1 (with exceptions)
[thirdparty/systemd.git] / man / sd-daemon.xml
CommitLineData
f9378423
LP
1<?xml version='1.0'?> <!--*-nxml-*-->
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5<!--
6 This file is part of systemd.
7
8 Copyright 2010 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
f9378423
LP
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 18 Lesser General Public License for more details.
f9378423 19
5430f7f2 20 You should have received a copy of the GNU Lesser General Public License
f9378423
LP
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22-->
23
24<refentry id="sd-daemon">
25
26 <refentryinfo>
27 <title>sd-daemon</title>
28 <productname>systemd</productname>
29
30 <authorgroup>
31 <author>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
36 </author>
37 </authorgroup>
38 </refentryinfo>
39
40 <refmeta>
41 <refentrytitle>sd-daemon</refentrytitle>
42 <manvolnum>7</manvolnum>
43 </refmeta>
44
45 <refnamediv>
46 <refname>sd-daemon</refname>
47 <refpurpose>Reference implementation of APIs for
48 new-style daemons</refpurpose>
49 </refnamediv>
50
51 <refsynopsisdiv>
52 <funcsynopsis>
a822cbfa 53 <funcsynopsisinfo>#include &lt;systemd/sd-daemon.h&gt;</funcsynopsisinfo>
f9378423 54 </funcsynopsis>
7712ea6d
LP
55
56 <cmdsynopsis>
57 <command>pkg-config --cflags --libs libsystemd-daemon</command>
58 </cmdsynopsis>
59
f9378423
LP
60 </refsynopsisdiv>
61
62 <refsect1>
63 <title>Description</title>
64
65 <para><filename>sd-daemon.c</filename> and
66 <filename>sd-daemon.h</filename> provide a reference
67 implementation of various APIs for new-style daemons,
68 as implemented by the
f3e219a2 69 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
f9378423
LP
70 init system.</para>
71
72 <para>See
73 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
74 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
75 <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
76 <citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>
77 for more information about the functions
78 implemented. In addition to these functions a couple
79 of logging prefixes are defined as macros:</para>
80
81 <programlisting>#define SD_EMERG "&lt;0&gt;" /* system is unusable */
82#define SD_ALERT "&lt;1&gt;" /* action must be taken immediately */
83#define SD_CRIT "&lt;2&gt;" /* critical conditions */
84#define SD_ERR "&lt;3&gt;" /* error conditions */
85#define SD_WARNING "&lt;4&gt;" /* warning conditions */
86#define SD_NOTICE "&lt;5&gt;" /* normal but significant condition */
87#define SD_INFO "&lt;6&gt;" /* informational */
88#define SD_DEBUG "&lt;7&gt;" /* debug-level messages */</programlisting>
89
90 <para>These prefixes are intended to be used in
91 conjunction with STDERR-based logging as implemented
92 by systemd. If a systemd service definition file is
93 configured with <varname>StandardError=syslog</varname>
94 or <varname>StandardError=kmsg</varname> these
95 prefixes can be used to encode a log level in lines
96 printed. This is similar to the kernel
97 <function>printk()</function>-style logging. See
98 <citerefentry><refentrytitle>klogctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
99 for more information.</para>
100
101 <para>The log levels are identical to
102 <citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>'s
103 log level system. To use these prefixes simply prefix
104 every line with one of these strings. A line that is
105 not prefixed will be logged at the default log level
106 SD_INFO.</para>
107
108 <example>
109 <title>Hello World</title>
110
111 <para>A daemon may log with the log level
112 NOTICE by issuing this call:</para>
113
114 <programlisting>fprintf(stderr, SD_NOTICE "Hello World!\n");</programlisting>
115 </example>
116 </refsect1>
117
118 <refsect1>
119 <title>Notes</title>
120
121 <para>These interfaces are provided by the reference
122 implementation of APIs for new-style daemons and
123 distributed with the systemd package. The algorithms
124 they implement are simple, and can easily be
125 reimplemented in daemons if it is important to support
126 this interface without using the reference
127 implementation. See the respective function man pages
128 for details.</para>
129
130 <para>In addition, for details about the algorithms
131 check the liberally licensed reference implementation
132 sources:
a26c9cc6
MB
133 <ulink url="http://cgit.freedesktop.org/systemd/systemd/plain/src/sd-daemon.c"/>
134 resp. <ulink url="http://cgit.freedesktop.org/systemd/systemd/plain/src/systemd/sd-daemon.h"/></para>
f9378423
LP
135
136 <para>These APIs are implemented in the reference
71e6c1cf
LP
137 implementation's <filename>sd-daemon.c</filename> and
138 <filename>sd-daemon.h</filename> files. These
139 interfaces are available as shared library, which can
140 be compiled and linked to with the
141 <literal>libsystemd-daemon</literal>
142 <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
143 file. Alternatively, applications consuming these APIs
144 may copy the implementation into their source tree,
145 either verbatim or in excerpts.</para>
f9378423
LP
146
147 <para>The functions directly related to new-style
148 daemons become NOPs when -DDISABLE_SYSTEMD is set
71e6c1cf
LP
149 during compilation and the reference implementation is
150 used as drop-in files. In addition, if
f9378423 151 <filename>sd-daemon.c</filename> is compiled on
af62c704 152 non-Linux systems they become NOPs.</para>
f9378423
LP
153 </refsect1>
154
155 <refsect1>
156 <title>See Also</title>
157 <para>
160cd5c9 158 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
f9378423
LP
159 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
160 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
161 <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
162 <citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
163 <citerefentry><refentrytitle>daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
f9378423
LP
164 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
165 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
e62e6670 166 <citerefentry><refentrytitle>fprintf</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
7712ea6d
LP
167 <citerefentry><refentrytitle>sd-readahead</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
168 <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
f9378423
LP
169 </para>
170 </refsect1>
171
172</refentry>