summaryrefslogtreecommitdiff
path: root/lib/libc/gen
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2001-12-07 19:59:51 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2001-12-07 19:59:51 +0000
commit9662a937db493485358bdc64f2a25bc658a3913c (patch)
treed422ca76c1ba8b5d4bbcce2c3d7c12b98b2e1b95 /lib/libc/gen
parent8048db076b329a267f2d956fb54f7b30a4719499 (diff)
Add CAVEATS section pointing out the dangers of closing fds <= 2
as found by Markus.
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/daemon.321
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/libc/gen/daemon.3 b/lib/libc/gen/daemon.3
index 8acc08b3b53..d90c38f6c2e 100644
--- a/lib/libc/gen/daemon.3
+++ b/lib/libc/gen/daemon.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: daemon.3,v 1.7 1999/09/22 22:01:25 aaron Exp $
+.\" $OpenBSD: daemon.3,v 1.8 2001/12/07 19:59:50 millert Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
@@ -81,3 +81,22 @@ The
.Fn daemon
function first appeared in
.Bx 4.4 .
+.Sh CAVEATS
+Unless the
+.Ar noclose
+argument is non-zero,
+.Fn daemon
+will close the first three file descriptors and redirect them to
+.Pa /dev/null .
+Normally, these correspond to standard input, standard output and
+standard error.
+However, if any of those file descriptors refer to something else they
+will still be closed, resulting in incorrect behavior of the calling program.
+This can happen if any of standard input, standard output or standard error
+have been closed before the program was run.
+Programs using
+.Fn daemon
+should therefor be care to either call
+.Fn daemon
+before opening any files or sockets or, alternately, verifying that
+any file descriptors obtained have a value greater than 2.