diff --git a/man/daemon.xml b/man/daemon.xml index 7724bb4e08d..41da01943c6 100644 --- a/man/daemon.xml +++ b/man/daemon.xml @@ -77,9 +77,10 @@ setsid() to detach from any terminal and create an independent session. - In the child, call fork() - again, to ensure that the daemon can never re-acquire a - terminal again. + In the child, call fork() 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.) Call exit() in the first child, so that only the second child (the actual daemon @@ -244,6 +245,10 @@ and systemd.exec5. + 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. + These recommendations are similar but not identical to the