man: mention O_NOCTTY and it's importance in daemon(7)

Fixes: #9164
This commit is contained in:
Lennart Poettering 2019-03-13 16:55:46 +01:00
parent e178b335f5
commit 5f42830079

View file

@ -77,9 +77,10 @@
<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
@ -244,6 +245,10 @@
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