]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd-daemon.xml
man: document that sd-daemon.[ch] is now available as shared library
[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
11 under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
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
18 General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
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>
53 <funcsynopsisinfo>#include "sd-daemon.h"</funcsynopsisinfo>
54 </funcsynopsis>
55 </refsynopsisdiv>
56
57 <refsect1>
58 <title>Description</title>
59
60 <para><filename>sd-daemon.c</filename> and
61 <filename>sd-daemon.h</filename> provide a reference
62 implementation of various APIs for new-style daemons,
63 as implemented by the
f3e219a2 64 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
f9378423
LP
65 init system.</para>
66
67 <para>See
68 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
69 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
70 <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
71 <citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>
72 for more information about the functions
73 implemented. In addition to these functions a couple
74 of logging prefixes are defined as macros:</para>
75
76 <programlisting>#define SD_EMERG "&lt;0&gt;" /* system is unusable */
77#define SD_ALERT "&lt;1&gt;" /* action must be taken immediately */
78#define SD_CRIT "&lt;2&gt;" /* critical conditions */
79#define SD_ERR "&lt;3&gt;" /* error conditions */
80#define SD_WARNING "&lt;4&gt;" /* warning conditions */
81#define SD_NOTICE "&lt;5&gt;" /* normal but significant condition */
82#define SD_INFO "&lt;6&gt;" /* informational */
83#define SD_DEBUG "&lt;7&gt;" /* debug-level messages */</programlisting>
84
85 <para>These prefixes are intended to be used in
86 conjunction with STDERR-based logging as implemented
87 by systemd. If a systemd service definition file is
88 configured with <varname>StandardError=syslog</varname>
89 or <varname>StandardError=kmsg</varname> these
90 prefixes can be used to encode a log level in lines
91 printed. This is similar to the kernel
92 <function>printk()</function>-style logging. See
93 <citerefentry><refentrytitle>klogctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
94 for more information.</para>
95
96 <para>The log levels are identical to
97 <citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>'s
98 log level system. To use these prefixes simply prefix
99 every line with one of these strings. A line that is
100 not prefixed will be logged at the default log level
101 SD_INFO.</para>
102
103 <example>
104 <title>Hello World</title>
105
106 <para>A daemon may log with the log level
107 NOTICE by issuing this call:</para>
108
109 <programlisting>fprintf(stderr, SD_NOTICE "Hello World!\n");</programlisting>
110 </example>
111 </refsect1>
112
113 <refsect1>
114 <title>Notes</title>
115
116 <para>These interfaces are provided by the reference
117 implementation of APIs for new-style daemons and
118 distributed with the systemd package. The algorithms
119 they implement are simple, and can easily be
120 reimplemented in daemons if it is important to support
121 this interface without using the reference
122 implementation. See the respective function man pages
123 for details.</para>
124
125 <para>In addition, for details about the algorithms
126 check the liberally licensed reference implementation
127 sources:
128 <ulink url="http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.c"/>
129 resp. <ulink url="http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.h"/></para>
130
131 <para>These APIs are implemented in the reference
71e6c1cf
LP
132 implementation's <filename>sd-daemon.c</filename> and
133 <filename>sd-daemon.h</filename> files. These
134 interfaces are available as shared library, which can
135 be compiled and linked to with the
136 <literal>libsystemd-daemon</literal>
137 <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
138 file. Alternatively, applications consuming these APIs
139 may copy the implementation into their source tree,
140 either verbatim or in excerpts.</para>
f9378423
LP
141
142 <para>The functions directly related to new-style
143 daemons become NOPs when -DDISABLE_SYSTEMD is set
71e6c1cf
LP
144 during compilation and the reference implementation is
145 used as drop-in files. In addition, if
f9378423 146 <filename>sd-daemon.c</filename> is compiled on
af62c704 147 non-Linux systems they become NOPs.</para>
f9378423
LP
148 </refsect1>
149
150 <refsect1>
151 <title>See Also</title>
152 <para>
160cd5c9 153 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
f9378423
LP
154 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
155 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
156 <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
157 <citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
158 <citerefentry><refentrytitle>daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
f9378423
LP
159 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
160 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
e62e6670
LP
161 <citerefentry><refentrytitle>fprintf</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
162 <citerefentry><refentrytitle>sd-readahead</refentrytitle><manvolnum>7</manvolnum></citerefentry>
f9378423
LP
163 </para>
164 </refsect1>
165
166</refentry>