summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/daemon.3
diff options
context:
space:
mode:
authorghelmer <ghelmer@FreeBSD.org>2003-11-10 22:01:42 +0000
committerghelmer <ghelmer@FreeBSD.org>2003-11-10 22:01:42 +0000
commitc5fcb1b2254d6529beea09a47bd70da6b98220f5 (patch)
tree0943c2b70e62ac5fe23f445330e4679ec07ddff1 /lib/libc/gen/daemon.3
parent230f4975473b2bcb96199197e4ea9b0b5455abc0 (diff)
downloadFreeBSD-src-c5fcb1b2254d6529beea09a47bd70da6b98220f5.zip
FreeBSD-src-c5fcb1b2254d6529beea09a47bd70da6b98220f5.tar.gz
Prevent abnormal termination of a child daemon process when created
by a parent that is a session leader (e.g., login shell) by ignoring SIGHUP in before calling fork(2) and then restoring SIGHUP's action after setsid(3). Based on the patch by Martin Kammerhofer <mkamm@gmx.net>. PR: bin/25462 Reviewed by: bde, alex.neyman@auriga.ru
Diffstat (limited to 'lib/libc/gen/daemon.3')
-rw-r--r--lib/libc/gen/daemon.317
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/libc/gen/daemon.3 b/lib/libc/gen/daemon.3
index a08d0df..97025e6 100644
--- a/lib/libc/gen/daemon.3
+++ b/lib/libc/gen/daemon.3
@@ -71,12 +71,13 @@ The
function may fail and set
.Va errno
for any of the errors specified for the library functions
-.Xr fork 2
+.Xr fork 2 ,
and
.Xr setsid 2 .
.Sh SEE ALSO
.Xr fork 2 ,
-.Xr setsid 2
+.Xr setsid 2 ,
+.Xr sigaction 2
.Sh HISTORY
The
.Fn daemon
@@ -101,3 +102,15 @@ should therefore either call
.Fn daemon
before opening any files or sockets, or verify that any file
descriptors obtained have values greater than 2.
+.Pp
+The
+.Fn daemon
+function temporarily ignores
+.Dv SIGHUP
+while calling
+.Xr setsid 2
+to prevent a parent session group leader's calls to
+.Xr fork 2
+and then
+.Xr _exit 2
+from prematurely terminating the child process.
OpenPOWER on IntegriCloud