ktrace -C will return an error if you don't have a ktrace.out file because
sys_ktrace tries to open it whenever it has a filename, even if it won't be
used. I think it is more consistent to require it be null, so that we aren't
opening files we won't be using.
man page and utility diff below.
Index: usr.bin/ktrace/ktrace.c
===
RCS file: /cvs/src/usr.bin/ktrace/ktrace.c,v
retrieving revision 1.34
diff -u -p -r1.34 ktrace.c
--- usr.bin/ktrace/ktrace.c 11 Jun 2017 17:32:19 - 1.34
+++ usr.bin/ktrace/ktrace.c 6 Dec 2018 20:23:52 -
@@ -110,6 +110,7 @@ main(int argc, char *argv[])
break;
case 'C':
clear = CLEARALL;
+ tracefile = NULL;
pidset = 1;
break;
case 'c':
Index: lib/libc/sys/ktrace.2
===
RCS file: /cvs/src/lib/libc/sys/ktrace.2,v
retrieving revision 1.36
diff -u -p -r1.36 ktrace.2
--- lib/libc/sys/ktrace.2 19 Jun 2018 15:39:01 - 1.36
+++ lib/libc/sys/ktrace.2 6 Dec 2018 20:30:07 -
@@ -61,11 +61,8 @@ If tracing points are being disabled (se
.Dv KTROP_CLEAR
below),
.Fa tracefile
-may be
-.Dv NULL
-or
-.Fa tracefd
-may be -1.
+must be
+.Dv NULL .
.Pp
Trace records are always appended to the file, ignoring the file offset,
so the caller will usually want to truncate the file before calling