<orderedlist>
<listitem><para>Close all open file
- descriptors except stdin, stdout,
- stderr (i.e. the first three file
+ descriptors except standard input, output,
+ and error (i.e. the first three file
descriptors 0, 1, 2). This ensures
that no accidentally passed file
descriptor stays around in the daemon
it is verified at the same time that
the PID previously stored in the PID
file no longer exists or belongs to a
- foreign process. Commonly, some kind of
- file locking is employed to implement
- this logic.</para></listitem>
+ foreign process.</para></listitem>
<listitem><para>In the daemon process,
drop privileges, if possible and
interface.</para></listitem>
<listitem><para>Instead of using the
- <function>syslog()</function> call to log directly to the
- system syslog service, a new-style daemon may
- choose to simply log to standard error via
- <function>fprintf()</function>, which is then forwarded to
- syslog by the init system. If log
- priorities are necessary, these can be
- encoded by prefixing individual log
- lines with strings like "<4>"
- (for log priority 4 "WARNING" in the
- syslog priority scheme), following a
- similar style as the Linux kernel's
- <function>printk()</function> priority system. In fact,
- using this style of logging also
- enables the init system to optionally
- direct all application logging to the
- kernel log buffer (kmsg), as
- accessible via
- <citerefentry><refentrytitle>dmesg</refentrytitle><manvolnum>1</manvolnum></citerefentry>. This
- kind of logging may be enabled by
- setting
- <varname>StandardError=syslog</varname>
- in the service unit file. For details,
- see
+ <function>syslog()</function> call to
+ log directly to the system syslog
+ service, a new-style daemon may choose
+ to simply log to standard error via
+ <function>fprintf()</function>, which
+ is then forwarded to syslog by the
+ init system. If log priorities are
+ necessary, these can be encoded by
+ prefixing individual log lines with
+ strings like "<4>" (for log
+ priority 4 "WARNING" in the syslog
+ priority scheme), following a similar
+ style as the Linux kernel's
+ <function>printk()</function> priority
+ system. For details, see
<citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>
and
<citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para></listitem>
<para>These recommendations are similar but
not identical to the <ulink
- url="http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/LaunchOnDemandDaemons.html#//apple_ref/doc/uid/TP40001762-104738">Apple
+ url="https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html">Apple
MacOS X Daemon Requirements</ulink>.</para>
</refsect2>
</orderedlist>
</refsect1>
+ <refsect1>
+ <title>Placing Daemon Data</title>
+
+ <para>It is recommended to follow the general
+ guidelines for placing package files, as discussed in
+ <citerefentry><refentrytitle>file-hierarchy</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</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>daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
- <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+ <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>file-hierarchy</refentrytitle><manvolnum>7</manvolnum></citerefentry>
</para>
</refsect1>