chiark / gitweb /
socket: don't allow mixing of accepting and non-accepting sockets in the same unit
[elogind.git] / man / sd-daemon.xml
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
64                 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
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
132                 implementation's drop-in
133                 <filename>sd-daemon.c</filename> and
134                 <filename>sd-daemon.h</filename> files. It is
135                 recommended that applications consuming these APIs copy
136                 the implementation into their source tree, either
137                 verbatim or in excerpts. These interfaces are
138                 currently not available in a dynamic library.</para>
139
140                 <para>The functions directly related to new-style
141                 daemons become NOPs when -DDISABLE_SYSTEMD is set
142                 during compilation. In addition, if
143                 <filename>sd-daemon.c</filename> is compiled on
144                 non-Linux systems they become NOPs.</para>
145         </refsect1>
146
147         <refsect1>
148                 <title>See Also</title>
149                 <para>
150                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
151                         <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
152                         <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
153                         <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
154                         <citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
155                         <citerefentry><refentrytitle>daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
156                         <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
157                         <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
158                         <citerefentry><refentrytitle>fprintf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
159                 </para>
160         </refsect1>
161
162 </refentry>