Commit f9378423 authored by Lennart Poettering's avatar Lennart Poettering

man: document sd-daemon.[ch]

parent a3723b97
......@@ -16,8 +16,10 @@ systemd-logger
systemctl
systemadm
.dirstamp
*.3
*.5
*.7
*.8
*.html
*~
*.tar.gz
......@@ -45,4 +47,6 @@ stamp-*
Makefile
ltmain.sh
*.tar.bz2
*.tar.gz
*.tar.xz
libtool
......@@ -307,7 +307,13 @@ EXTRA_DIST += \
dist_man_MANS = \
man/systemd.unit.5 \
man/systemd.service.5 \
man/daemon.7
man/daemon.7 \
man/systemd.8 \
man/sd_notify.3 \
man/sd_booted.3 \
man/sd_listen_fds.3 \
man/sd_is_fifo.3 \
man/sd-daemon.7
nodist_man_MANS = \
man/systemd.special.7
......@@ -315,7 +321,13 @@ nodist_man_MANS = \
dist_noinst_DATA = \
man/systemd.unit.html \
man/systemd.service.html \
man/daemon.html
man/daemon.html \
man/systemd.html \
man/sd_notify.html \
man/sd_booted.html \
man/sd_listen_fds.html \
man/sd_is_fifo.html \
man/sd-daemon.html
nodist_noinst_DATA = \
man/systemd.special.html
......@@ -326,7 +338,13 @@ EXTRA_DIST += \
man/systemd.special.xml.in \
man/systemd.special.7.in \
man/systemd.special.html.in \
man/daemon.xml
man/daemon.xml \
man/systemd.xml \
man/sd_notify.xml \
man/sd_booted.xml \
man/sd_listen_fds.xml \
man/sd_is_fifo.xml \
man/sd-daemon.xml
systemd_SOURCES = \
src/main.c
......@@ -570,6 +588,12 @@ XSLTPROC_PROCESS_HTML_IN = \
$(XSLTPROC) -o ${@:.in=} --nonet http://docbook.sourceforge.net/release/xsl/current/xhtml-1_1/docbook.xsl $< && \
mv ${@:.in=} $@
man/%.3: man/%.xml
$(XSLTPROC_PROCESS_MAN)
man/%.3.in: man/%.xml.in
$(XSLTPROC_PROCESS_MAN)
man/%.5: man/%.xml
$(XSLTPROC_PROCESS_MAN)
......@@ -582,6 +606,12 @@ man/%.7: man/%.xml
man/%.7.in: man/%.xml.in
$(XSLTPROC_PROCESS_MAN_IN)
man/%.8: man/%.xml
$(XSLTPROC_PROCESS_MAN)
man/%.8.in: man/%.xml.in
$(XSLTPROC_PROCESS_MAN_IN)
man/%.html: man/%.xml
$(XSLTPROC_PROCESS_HTML)
......
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
This file is part of systemd.
Copyright 2010 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
-->
<refentry id="sd-daemon">
<refentryinfo>
<title>sd-daemon</title>
<productname>systemd</productname>
<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Lennart</firstname>
<surname>Poettering</surname>
<email>lennart@poettering.net</email>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>sd-daemon</refentrytitle>
<manvolnum>7</manvolnum>
</refmeta>
<refnamediv>
<refname>sd-daemon</refname>
<refpurpose>Reference implementation of APIs for
new-style daemons</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include "sd-daemon.h"</funcsynopsisinfo>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><filename>sd-daemon.c</filename> and
<filename>sd-daemon.h</filename> provide a reference
implementation of various APIs for new-style daemons,
as implemented by the
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry>
init system.</para>
<para>See
<citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>
for more information about the functions
implemented. In addition to these functions a couple
of logging prefixes are defined as macros:</para>
<programlisting>#define SD_EMERG "&lt;0&gt;" /* system is unusable */
#define SD_ALERT "&lt;1&gt;" /* action must be taken immediately */
#define SD_CRIT "&lt;2&gt;" /* critical conditions */
#define SD_ERR "&lt;3&gt;" /* error conditions */
#define SD_WARNING "&lt;4&gt;" /* warning conditions */
#define SD_NOTICE "&lt;5&gt;" /* normal but significant condition */
#define SD_INFO "&lt;6&gt;" /* informational */
#define SD_DEBUG "&lt;7&gt;" /* debug-level messages */</programlisting>
<para>These prefixes are intended to be used in
conjunction with STDERR-based logging as implemented
by systemd. If a systemd service definition file is
configured with <varname>StandardError=syslog</varname>
or <varname>StandardError=kmsg</varname> these
prefixes can be used to encode a log level in lines
printed. This is similar to the kernel
<function>printk()</function>-style logging. See
<citerefentry><refentrytitle>klogctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
for more information.</para>
<para>The log levels are identical to
<citerefentry><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>'s
log level system. To use these prefixes simply prefix
every line with one of these strings. A line that is
not prefixed will be logged at the default log level
SD_INFO.</para>
<example>
<title>Hello World</title>
<para>A daemon may log with the log level
NOTICE by issuing this call:</para>
<programlisting>fprintf(stderr, SD_NOTICE "Hello World!\n");</programlisting>
</example>
</refsect1>
<refsect1>
<title>Notes</title>
<para>These interfaces are provided by the reference
implementation of APIs for new-style daemons and
distributed with the systemd package. The algorithms
they implement are simple, and can easily be
reimplemented in daemons if it is important to support
this interface without using the reference
implementation. See the respective function man pages
for details.</para>
<para>In addition, for details about the algorithms
check the liberally licensed reference implementation
sources:
<ulink url="http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.c"/>
resp. <ulink url="http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.h"/></para>
<para>These APIs are implemented in the reference
implementation's drop-in
<filename>sd-daemon.c</filename> and
<filename>sd-daemon.h</filename> files. It is
recommended that applications consuming these APIs copy
the implementation into their source tree, either
verbatim or in excerpts. These interfaces are
currently not available in a dynamic library.</para>
<para>The functions directly related to new-style
daemons become NOPs when -DDISABLE_SYSTEMD is set
during compilation. In addition, if
<filename>sd-daemon.c</filename> is compiled on
non-Linux systems they become NOPs, too.</para>
</refsect1>
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>fprintf</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
This file is part of systemd.
Copyright 2010 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
-->
<refentry id="sd_booted">
<refentryinfo>
<title>sd_booted</title>
<productname>systemd</productname>
<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Lennart</firstname>
<surname>Poettering</surname>
<email>lennart@poettering.net</email>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>sd_booted</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_booted</refname>
<refpurpose>Test whether the system is running the systemd init system.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include "sd-daemon.h"</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_booted</function></funcdef>
<paramdef>void</paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_booted()</function> checks whether
the system was booted up using the systemd init system.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On failure, this call returns a negative
errno-style error code. If the system was booted up
with systemd as init system this call returns a
postive return value, zero otherwise.</para>
</refsect1>
<refsect1>
<title>Notes</title>
<para>This function is provided by the reference
implementation of APIs for new-style daemons and
distributed with the systemd package. The algorithm it
implements is simple, and can easily be reimplemented
in daemons if it is important to support this
interface without using the reference
implementation.</para>
<para>Internally, this function checks whether the
<filename>/cgroup/systemd</filename> virtual file
system is mounted, by comparing the st_dev value of
the <function>stat()</function> data of
<filename>/cgroup</filename> and
<filename>/cgroup/systemd</filename>.</para>
<para>For details about the algorithm check the
liberally licensed reference implementation sources:
<ulink url="http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.c"/>
resp. <ulink
url="http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.h"/></para>
<para><function>sd_booted()</function> is implemented
in the reference implementation's drop-in
<filename>sd-daemon.c</filename> and
<filename>sd-daemon.h</filename> files. It is
recommended that applications consuming these APIs
copy the implementation into their source tree. For
more details about the reference implementation see
<citerefentry><refentrytitle>sd_daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry></para>
<para>If -DDISABLE_SYSTEMD is set during compilation
this function will always return 0 and otherwise
become a NOP.</para>
</refsect1>
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>sd_daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
This file is part of systemd.
Copyright 2010 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
-->
<refentry id="sd_is_fifo">
<refentryinfo>
<title>sd_is_fifo</title>
<productname>systemd</productname>
<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Lennart</firstname>
<surname>Poettering</surname>
<email>lennart@poettering.net</email>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>sd_is_fifo</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_is_fifo</refname>
<refname>sd_is_socket</refname>
<refname>sd_is_socket_inet</refname>
<refname>sd_is_socket_unix</refname>
<refpurpose>Check the type of a file descriptor</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include "sd-daemon.h"</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_is_fifo</function></funcdef>
<paramdef>int <parameter>fd</parameter></paramdef>
<paramdef>const char *<parameter>path</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_is_socket</function></funcdef>
<paramdef>int <parameter>fd</parameter></paramdef>
<paramdef>int <parameter>family</parameter></paramdef>
<paramdef>int <parameter>type</parameter></paramdef>
<paramdef>int <parameter>listening</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_is_socket_inet</function></funcdef>
<paramdef>int <parameter>fd</parameter></paramdef>
<paramdef>int <parameter>family</parameter></paramdef>
<paramdef>int <parameter>type</parameter></paramdef>
<paramdef>int <parameter>listening</parameter></paramdef>
<paramdef>uint16_t <parameter>port</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_is_socket_unix</function></funcdef>
<paramdef>int <parameter>fd</parameter></paramdef>
<paramdef>int <parameter>type</parameter></paramdef>
<paramdef>int <parameter>listening</parameter></paramdef>
<paramdef>const char* <parameter>path</parameter></paramdef>
<paramdef>size_t <parameter>length</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_is_fifo()</function> may be called
to check whether the specified file descriptor refers
to a FIFO or pipe. It the <parameter>path</parameter>
parameter is not NULL it is checked whether the FIFO
is bound to the specified file system path.</para>
<para><function>sd_is_socket()</function> may be
called to check whether the specified file descriptor
refers to a socket. It the
<parameter>family</parameter> parameter is not
AF_UNSPEC it is checked whether the socket is of the
specified family (AF_UNIX, AF_INET, ...). If the
<parameter>type</parameter> parameter is not 0 it is
checked whether the socket is of the specified type
(SOCK_STREAM, SOCK_DGRAM, ...). If the
<parameter>listening</parameter> parameter is positive
it is checked whether the socket is in accepting mode,
i.e. <function>listen()</function> has been called for
it. If <parameter>listening</parameter> is 0, it is
checked whether the socket is not in this mode. If the
parameter is negative, no such check is made. The
<parameter>listening</parameter> parameter should only
be used for stream sockets and should be set to a
negative value otherwise.</para>
<para><function>sd_is_socket_inet()</function> is
similar to <function>sd_is_socket()</function>, but
optionally checks the IPv4 or IPv6 port number the
socket is bound to, unless <parameter>port</parameter>
is zero. For this call <parameter>family</parameter>
must be passed as either AF_UNSPEC, AF_INET or
AF_INET6.</para>
<para><function>sd_is_socket_unix()</function> is
similar to <function>sd_is_socket()</function>, but
optionally checks the AF_UNIX path the socket is bound
to, unless the <parameter>path</parameter> parameter
is NULL. For normal file system AF_UNIX sockets set
the <parameter>length</parameter> parameter to 0. For
Linux abstract namespace sockets set the
<parameter>length</parameter> to the size of the
address, including the initial 0 byte and set
<parameter>path</parameter> to the initial 0 byte of
the socket address.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On failure, these calls return a negative
errno-style error code. If the file descriptor is of
the specified type and bound to the specified address
a positive return value is returned, otherwise
zero.</para>
</refsect1>
<refsect1>
<title>Notes</title>
<para>These functions are provided by the reference
implementation of APIs for new-style daemons and
distributed with the systemd package. The algorithms
they implement are simple, and can easily be
reimplemented in daemons if it is important to support
this interface without using the reference
implementation.</para>
<para>Internally, these function use a combination of
<filename>fstat()</filename> and
<filename>getsockname()</filename> to check the file
descriptor type and where it is bound to.</para>
<para>For details about the algorithm check the
liberally licensed reference implementation sources:
<ulink url="http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.c"/>
resp. <ulink
url="http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.h"/></para>
<para><function>sd_is_fifo()</function> and the
related functions are implemented in the reference
implementation's drop-in
<filename>sd-daemon.c</filename> and
<filename>sd-daemon.h</filename> files. It is
recommended that applications consuming these APIs
copy the implementation into their source tree. For
more details about the reference implementation see
<citerefentry><refentrytitle>sd_daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry></para>
<para>These functions continue to work as described,
even if -DDISABLE_SYSTEMD is set during
compilation.</para>
</refsect1>
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>sd_daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>
<?xml version='1.0'?> <!--*-nxml-*-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!--
This file is part of systemd.
Copyright 2010 Lennart Poettering
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
-->
<refentry id="sd_listen_fds">
<refentryinfo>
<title>sd_listen_fds</title>
<productname>systemd</productname>
<authorgroup>
<author>
<contrib>Developer</contrib>
<firstname>Lennart</firstname>
<surname>Poettering</surname>
<email>lennart@poettering.net</email>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
<refentrytitle>sd_listen_fds</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_listen_fds</refname>
<refpurpose>Check for file descriptors passed by the init system.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include "sd-daemon.h"</funcsynopsisinfo>
<funcsynopsisinfo>#define SD_LISTEN_FDS_START 3</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_listen_fds</function></funcdef>
<paramdef>int <parameter>unset_environment</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_listen_fds()</function> shall be
called by a daemon to check for file descriptors
passed by the init system as part of the socket-based
activation logic.</para>
<para>If the <parameter>unset_environment</parameter>
parameter is non-zero
<function>sd_listen_fds()</function> will unset the
<varname>$LISTEN_FDS</varname>/<varname>$LISTEN_PID</varname>
environment variables before returning (regardless
whether the function call itself succeeded or
not). Further calls to
<function>sd_listen_fds()</function> will then fail,
but the variables are no longer inherited by child
processes.</para>
<para>If a daemon receives more than one file
descriptor, they will be passed in the same order as
configured in the systemd socket definition
file. Nonetheless it is recommended to verify the
correct socket types before using them. To simplify
this checking the functions
<citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_is_socket</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_is_socket_inet</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_is_socket_unix</refentrytitle><manvolnum>3</manvolnum></citerefentry>
are provided. In order to maximize flexibility it is
recommened to make these checks as loose as possible
without allowing incorrect setups. i.e. often the
actual port number a socket is bound to matters little
for the service to work, hence it should not be
verified. On the other hand, whether a socket is a
datagram or stream socket matters a lot for the most
common program logics and should hence be
checked.</para>
<para>This function call will set the FD_CLOEXEC flag
for all passed file descriptors to avoid further
inheritance to children of the calling process.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On failure, this call returns a negative
errno-style error code. If
<varname>$LISTEN_FDS</varname>/<varname>$LISTEN_PID</varname>
was not set or not correctly set for this daemon and
hence no file descriptors received 0 is
returned. Otherwise the number of file descriptors
passed is returned, the application may find them
starting with file descriptor SD_LISTEN_FDS_START,
i.e. file descriptor 3.</para>
</refsect1>
<refsect1>
<title>Notes</title>
<para>This function is provided by the reference
implementation of APIs for new-style daemons and
distributed with the systemd package. The algorithm it
implements is simple, and can easily be reimplemented
in daemons if it is important to support this
interface without using the reference
implementation.</para>
<para>Internally, this function checks whether the
<varname>$LISTEN_PID</varname> environment variable
equals the daemon PID. If not, it returns
immediately. Otherwise it parses the number passed in
the <varname>$LISTEN_FDS</varname> environment
variable, then sets the FD_CLOEXEC flag for the parsed
number of file descriptors starting from
SD_LISTEN_FDS_START. Finally it returns the parsed
number.</para>
<para>For details about the algorithm check the
liberally licensed reference implementation sources:
<ulink url="http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.c"/>
resp. <ulink
url="http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.h"/></para>
<para><function>sd_listen_fds()</function> is
implemented in the reference implementation's drop-in
<filename>sd-daemon.c</filename> and
<filename>sd-daemon.h</filename> files. It is
recommended that applications consuming these APIs
copy the implementation into their source tree. For
more details about the reference implementation see
<citerefentry><refentrytitle>sd_daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry></para>
<para>If -DDISABLE_SYSTEMD is set during compilation
this function will always return 0 and otherwise
become a NOP.</para>
</refsect1>
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>sd_daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_is_socket</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_is_socket_inet</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_is_socket_unix</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>
This diff is collapsed.
......@@ -76,7 +76,7 @@ extern "C" {
/*
Log levels for usage on stderr:
fprintf(stderr, SD_NOTICE "Hello World!");