sd-daemon.xml revision 8ab49c12dcab02d9d83e63a93676d4fc8f709516
97a9a944b5887e91042b019776c41d5dd74557aferikabele<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
97a9a944b5887e91042b019776c41d5dd74557aferikabele "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
8c81ebbdeed67059e7a1106d7c617543e901c3abyoshiki This file is part of systemd.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd Copyright 2010 Lennart Poettering
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 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.
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/>.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <refentryinfo>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <authorgroup>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </authorgroup>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </refentryinfo>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </refmeta>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <refnamediv>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <refpurpose>Reference implementation of APIs for
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd new-style daemons</refpurpose>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </refnamediv>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <refsynopsisdiv>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <funcsynopsis>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <funcsynopsisinfo>#include <systemd/sd-daemon.h></funcsynopsisinfo>
f61ec47ec494705bd2d02b5b6fe021e5c193f2c8noodl </funcsynopsis>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <cmdsynopsis>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd <command>pkg-config --cflags --libs libsystemd-daemon</command>
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd </cmdsynopsis>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive </refsynopsisdiv>
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 <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 <programlisting>#define SD_EMERG "<0>" /* system is unusable */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#define SD_ALERT "<1>" /* action must be taken immediately */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#define SD_CRIT "<2>" /* critical conditions */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#define SD_ERR "<3>" /* error conditions */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#define SD_WARNING "<4>" /* warning conditions */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#define SD_NOTICE "<5>" /* normal but significant condition */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#define SD_INFO "<6>" /* informational */
06ba4a61654b3763ad65f52283832ebf058fdf1cslive#define SD_DEBUG "<7>" /* debug-level messages */</programlisting>
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 prefixes can be used to encode a log level in lines
e1e8390280254f7f0580d701e583f670643d4f3fnilgun printed. This is similar to the kernel
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <citerefentry><refentrytitle>klogctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun for more information.</para>
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 <para>A daemon may log with the log level
e1e8390280254f7f0580d701e583f670643d4f3fnilgun NOTICE by issuing this call:</para>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun <programlisting>fprintf(stderr, SD_NOTICE "Hello World!\n");</programlisting>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun </refsect1>
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>
06ba4a61654b3763ad65f52283832ebf058fdf1cslive <para>In addition, for details about the algorithms
e1e8390280254f7f0580d701e583f670643d4f3fnilgun check the liberally licensed reference implementation
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 <para>These APIs are implemented in the reference
e1e8390280254f7f0580d701e583f670643d4f3fnilgun implementation's <filename>sd-daemon.c</filename> and
e1e8390280254f7f0580d701e583f670643d4f3fnilgun interfaces are available as shared library, which can
e1e8390280254f7f0580d701e583f670643d4f3fnilgun be compiled and linked to with the
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 <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 non-Linux systems they become NOPs.</para>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun </refsect1>
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>
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf </refsect1>
a5a2e98043365d3f5a8bb3c3cdfc252a4f11bf02nd</refentry>