Op 05/18/16 om 01:49 schreef Edgar Pettijohn:
The wording made it hard for me to understand at first. The "unless"
"non-zero" seem like double negatives.
Index: daemon.3
===================================================================
RCS file: /cvs/src/lib/libc/gen/daemon.3,v
retrieving revision 1.12
diff -u -p -u -r1.12 daemon.3
--- daemon.3 5 Jun 2013 03:39:22 -0000 1.12
+++ daemon.3 17 May 2016 23:42:25 -0000
@@ -43,16 +43,16 @@ The
function is for programs wishing to detach themselves from the
controlling terminal and run in the background as system daemons.
.Pp
-Unless the argument
+If the argument
.Fa nochdir
-is non-zero,
+is zero,
.Fn daemon
changes the current working directory to the root
.Pq Pa / .
.Pp
-Unless the argument
+If the argument
.Fa noclose
-is non-zero,
+is zero,
.Fn daemon
will redirect standard input, standard output and standard error to
.Pa /dev/null .
You overlooked a double negation in the CAVEATS section.
I personally think the cause of confusion is the negated parameters,
"nochdir" and "noclose", so in my mind your patch still leaves the
confusion in place.
I'd like to propose the following:
Don't use negated parameters by renaming "nochdr" to "cd" and "noclose"
to "redir" and adjust the man page accordingly. I didn't rename
"nochdir" to "chdir" and "noclose" to "close" to avoid name clashes with
chdir(2) and close(2))
Does the following patch provide a clear enough description ?
Index: daemon.3
===================================================================
RCS file: /cvs/src/lib/libc/gen/daemon.3,v
retrieving revision 1.12
diff -u -p -u -r1.12 daemon.3
--- daemon.3 5 Jun 2013 03:39:22 -0000 1.12
+++ daemon.3 18 May 2016 08:10:07 -0000
@@ -36,22 +36,22 @@
.Sh SYNOPSIS
.In stdlib.h
.Ft int
-.Fn daemon "int nochdir" "int noclose"
+.Fn daemon "int cd" "int redir"
.Sh DESCRIPTION
The
.Fn daemon
function is for programs wishing to detach themselves from the
controlling terminal and run in the background as system daemons.
.Pp
-Unless the argument
-.Fa nochdir
+If the argument
+.Fa cd
is non-zero,
.Fn daemon
changes the current working directory to the root
.Pq Pa / .
.Pp
-Unless the argument
-.Fa noclose
+If the argument
+.Fa redir
is non-zero,
.Fn daemon
will redirect standard input, standard output and standard error to
@@ -78,8 +78,8 @@ The
function first appeared in
.Bx 4.4 .
.Sh CAVEATS
-Unless the
-.Ar noclose
+If the
+.Ar redir
argument is non-zero,
.Fn daemon
will close the first three file descriptors and redirect them to