sd-daemon.xml revision 8ab49c12dcab02d9d83e63a93676d4fc8f709516
97a9a944b5887e91042b019776c41d5dd74557aferikabele<?xml version='1.0'?> <!--*-nxml-*-->
97a9a944b5887e91042b019776c41d5dd74557aferikabele<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
97a9a944b5887e91042b019776c41d5dd74557aferikabele "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
8c81ebbdeed67059e7a1106d7c617543e901c3abyoshiki
8c81ebbdeed67059e7a1106d7c617543e901c3abyoshiki<!--
8c81ebbdeed67059e7a1106d7c617543e901c3abyoshiki This file is part of systemd.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd Copyright 2010 Lennart Poettering
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd systemd is free software; you can redistribute it and/or modify it
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd under the terms of the GNU General Public License as published by
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd the Free Software Foundation; either version 2 of the License, or
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd (at your option) any later version.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd systemd is distributed in the hope that it will be useful, but
3f08db06526d6901aa08c110b5bc7dde6bc39905nd WITHOUT ANY WARRANTY; without even the implied warranty of
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd General Public License for more details.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
3f08db06526d6901aa08c110b5bc7dde6bc39905nd You should have received a copy of the GNU General Public License
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd along with systemd; If not, see <http://www.gnu.org/licenses/>.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd-->
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<refentry id="sd-daemon">
7f5b59ccc63c0c0e3e678a168f09ee6a2f51f9d0nd
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <refentryinfo>
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung <title>sd-daemon</title>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd <productname>systemd</productname>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <authorgroup>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <author>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <contrib>Developer</contrib>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <firstname>Lennart</firstname>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <surname>Poettering</surname>
8c81ebbdeed67059e7a1106d7c617543e901c3abyoshiki <email>lennart@poettering.net</email>
8c81ebbdeed67059e7a1106d7c617543e901c3abyoshiki </author>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </authorgroup>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </refentryinfo>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <refmeta>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <refentrytitle>sd-daemon</refentrytitle>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <manvolnum>7</manvolnum>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </refmeta>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <refnamediv>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <refname>sd-daemon</refname>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <refpurpose>Reference implementation of APIs for
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd new-style daemons</refpurpose>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </refnamediv>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <refsynopsisdiv>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <funcsynopsis>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <funcsynopsisinfo>#include &lt;systemd/sd-daemon.h&gt;</funcsynopsisinfo>
f61ec47ec494705bd2d02b5b6fe021e5c193f2c8noodl </funcsynopsis>
f61ec47ec494705bd2d02b5b6fe021e5c193f2c8noodl
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <cmdsynopsis>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <command>pkg-config --cflags --libs libsystemd-daemon</command>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </cmdsynopsis>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </refsynopsisdiv>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <refsect1>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <title>Description</title>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <para><filename>sd-daemon.c</filename> and
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <filename>sd-daemon.h</filename> provide a reference
06ba4a61654b3763ad65f52283832ebf058fdf1cslive implementation of various APIs for new-style daemons,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive as implemented by the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive init system.</para>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <para>See
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive for more information about the functions
06ba4a61654b3763ad65f52283832ebf058fdf1cslive implemented. In addition to these functions a couple
06ba4a61654b3763ad65f52283832ebf058fdf1cslive of logging prefixes are defined as macros:</para>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <programlisting>#define SD_EMERG "&lt;0&gt;" /* system is unusable */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#define SD_ALERT "&lt;1&gt;" /* action must be taken immediately */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#define SD_CRIT "&lt;2&gt;" /* critical conditions */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#define SD_ERR "&lt;3&gt;" /* error conditions */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#define SD_WARNING "&lt;4&gt;" /* warning conditions */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#define SD_NOTICE "&lt;5&gt;" /* normal but significant condition */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#define SD_INFO "&lt;6&gt;" /* informational */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#define SD_DEBUG "&lt;7&gt;" /* debug-level messages */</programlisting>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <para>These prefixes are intended to be used in
06ba4a61654b3763ad65f52283832ebf058fdf1cslive conjunction with STDERR-based logging as implemented
06ba4a61654b3763ad65f52283832ebf058fdf1cslive by systemd. If a systemd service definition file is
82178a3043043b8813c0d7288a06ca1b7d110d4atakashi configured with <varname>StandardError=syslog</varname>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive or <varname>StandardError=kmsg</varname> these
06ba4a61654b3763ad65f52283832ebf058fdf1cslive prefixes can be used to encode a log level in lines
e1e8390280254f7f0580d701e583f670643d4f3fnilgun printed. This is similar to the kernel
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <function>printk()</function>-style logging. See
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <citerefentry><refentrytitle>klogctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun for more information.</para>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <para>The log levels are identical to
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>'s
e1e8390280254f7f0580d701e583f670643d4f3fnilgun log level system. To use these prefixes simply prefix
e1e8390280254f7f0580d701e583f670643d4f3fnilgun every line with one of these strings. A line that is
e1e8390280254f7f0580d701e583f670643d4f3fnilgun not prefixed will be logged at the default log level
e1e8390280254f7f0580d701e583f670643d4f3fnilgun SD_INFO.</para>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <example>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <title>Hello World</title>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <para>A daemon may log with the log level
e1e8390280254f7f0580d701e583f670643d4f3fnilgun NOTICE by issuing this call:</para>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <programlisting>fprintf(stderr, SD_NOTICE "Hello World!\n");</programlisting>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun </example>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun </refsect1>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <refsect1>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <title>Notes</title>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <para>These interfaces are provided by the reference
3a6531f1fd50efd78381e5800802a1449096781eslive implementation of APIs for new-style daemons and
3a6531f1fd50efd78381e5800802a1449096781eslive distributed with the systemd package. The algorithms
3a6531f1fd50efd78381e5800802a1449096781eslive they implement are simple, and can easily be
97a9a944b5887e91042b019776c41d5dd74557aferikabele reimplemented in daemons if it is important to support
3a6531f1fd50efd78381e5800802a1449096781eslive this interface without using the reference
e1e8390280254f7f0580d701e583f670643d4f3fnilgun implementation. See the respective function man pages
06ba4a61654b3763ad65f52283832ebf058fdf1cslive for details.</para>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <para>In addition, for details about the algorithms
e1e8390280254f7f0580d701e583f670643d4f3fnilgun check the liberally licensed reference implementation
e1e8390280254f7f0580d701e583f670643d4f3fnilgun sources:
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <ulink url="http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.c"/>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun resp. <ulink url="http://cgit.freedesktop.org/systemd/plain/src/systemd/sd-daemon.h"/></para>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <para>These APIs are implemented in the reference
e1e8390280254f7f0580d701e583f670643d4f3fnilgun implementation's <filename>sd-daemon.c</filename> and
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <filename>sd-daemon.h</filename> files. These
e1e8390280254f7f0580d701e583f670643d4f3fnilgun interfaces are available as shared library, which can
e1e8390280254f7f0580d701e583f670643d4f3fnilgun be compiled and linked to with the
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <literal>libsystemd-daemon</literal>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun file. Alternatively, applications consuming these APIs
e1e8390280254f7f0580d701e583f670643d4f3fnilgun may copy the implementation into their source tree,
06ba4a61654b3763ad65f52283832ebf058fdf1cslive either verbatim or in excerpts.</para>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <para>The functions directly related to new-style
e06675c51d084791089d79c3ac18aeae8dd465fcrbb daemons become NOPs when -DDISABLE_SYSTEMD is set
e1e8390280254f7f0580d701e583f670643d4f3fnilgun during compilation and the reference implementation is
e1e8390280254f7f0580d701e583f670643d4f3fnilgun used as drop-in files. In addition, if
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <filename>sd-daemon.c</filename> is compiled on
e1e8390280254f7f0580d701e583f670643d4f3fnilgun non-Linux systems they become NOPs.</para>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun </refsect1>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <refsect1>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <title>See Also</title>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <para>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
2f46ce2a814d7f2b126dfb9f1b25fd64e2fbdc11rbowen <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <citerefentry><refentrytitle>daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <citerefentry><refentrytitle>fprintf</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <citerefentry><refentrytitle>sd-readahead</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
25d005c58102474e06fb67d748273b161d7198d0pquerna <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
a5a2e98043365d3f5a8bb3c3cdfc252a4f11bf02nd </para>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf </refsect1>
a5a2e98043365d3f5a8bb3c3cdfc252a4f11bf02nd
a5a2e98043365d3f5a8bb3c3cdfc252a4f11bf02nd</refentry>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd