]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - man/daemon.xml
travis: add more ASan options
[thirdparty/systemd.git] / man / daemon.xml
index b6125cb5c7f6fa2a5318bb39e8e033d3e231cd95..79ea55ba26536eda78ad18ce97d7df65eb40c65b 100644 (file)
@@ -1,40 +1,13 @@
 <?xml version='1.0'?> <!--*-nxml-*-->
-<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//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 Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 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
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
--->
+<!-- SPDX-License-Identifier: LGPL-2.1+ -->
 
 <refentry id="daemon">
 
   <refentryinfo>
     <title>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>
         <function>setsid()</function> to detach from any terminal and
         create an independent session.</para></listitem>
 
-        <listitem><para>In the child, call <function>fork()</function>
-        again, to ensure that the daemon can never re-acquire a
-        terminal again.</para></listitem>
+        <listitem><para>In the child, call <function>fork()</function> again, to ensure that the daemon can
+        never re-acquire a terminal again. (This relevant if the program — and all its dependencies — does
+        not carefully specify `O_NOCTTY` on each and every single `open()` call that might potentially open a
+        TTY device node.)</para></listitem>
 
         <listitem><para>Call <function>exit()</function> in the first
         child, so that only the second child (the actual daemon
       functionality of the init system, it is recommended not to
       execute them when run as new-style service.</para>
 
-      <para>Note that new-style init systems guarantee execution of
-      daemon processes in a clean process context: it is guaranteed
-      that the environment block is sanitized, that the signal
-      handlers and mask is reset and that no left-over file
-      descriptors are passed. Daemons will be executed in their own
-      session, with standard input/output/error connected to
-      <filename>/dev/null</filename> unless otherwise configured. The
-      umask is reset.
+      <para>Note that new-style init systems guarantee execution of daemon processes in a clean process context: it is
+      guaranteed that the environment block is sanitized, that the signal handlers and mask is reset and that no
+      left-over file descriptors are passed. Daemons will be executed in their own session, with standard input
+      connected to <filename>/dev/null</filename> and standard output/error connected to the
+      <citerefentry><refentrytitle>systemd-journald.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+      logging service, unless otherwise configured. The umask is reset.
       </para>
 
       <para>It is recommended for new-style daemons to implement the
         bus-activatable by supplying a D-Bus service activation
         configuration file. This has multiple advantages: your daemon
         may be started lazily on-demand; it may be started in parallel
-        to other daemons requiring it -- which maximizes
+        to other daemons requiring it  which maximizes
         parallelization and boot-up speed; your daemon can be
         restarted on failure without losing any bus requests, as the
         bus queues requests for activatable services. See below for
         and
         <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para></listitem>
 
+        <listitem><para>As new-style daemons are invoked without a controlling TTY (but as their own session
+        leaders) care should be taken to always specify `O_NOCTTY` on `open()` calls that possibly reference
+        a TTY device node, so that no controlling TTY is accidentally acquired.</para></listitem>
+
       </orderedlist>
 
       <para>These recommendations are similar but not identical to the
 
   </refsect1>
   <refsect1>
-    <title>Integration with Systemd</title>
+    <title>Integration with systemd</title>
 
     <refsect2>
-      <title>Writing Systemd Unit Files</title>
+      <title>Writing systemd Unit Files</title>
 
       <para>When writing systemd unit files, it is recommended to
       consider the following suggestions:</para>
     </refsect2>
 
     <refsect2>
-      <title>Installing Systemd Service Files</title>
+      <title>Installing systemd Service Files</title>
 
       <para>At the build installation time (e.g. <command>make
       install</command> during package build), packages are
@@ -619,7 +595,7 @@ AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])</p
       <citerefentry project='die-net'><refentrytitle>automake</refentrytitle><manvolnum>1</manvolnum></citerefentry>-based
       projects:</para>
 
-      <programlisting>DISTCHECK_CONFIGURE_FLAGS = \
+      <programlisting>AM_DISTCHECK_CONFIGURE_FLAGS = \
   --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)</programlisting>
 
       <para>Finally, unit files should be installed in the system with an automake excerpt like the following:</para>