summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorjraynard <jraynard@FreeBSD.org>1996-06-19 09:56:30 +0000
committerjraynard <jraynard@FreeBSD.org>1996-06-19 09:56:30 +0000
commit30b42b6dfff6513bc654b0bc6f1388eda0d8ea77 (patch)
tree11cfd3e91859be35816bb3f0c3e99bdc9dd30057 /usr.bin
parent8980001a22297678bb03bba221e1560c284200a0 (diff)
downloadFreeBSD-src-30b42b6dfff6513bc654b0bc6f1388eda0d8ea77.zip
FreeBSD-src-30b42b6dfff6513bc654b0bc6f1388eda0d8ea77.tar.gz
Merged in 4.4Lite2 versions, added $Id$'s. The ktrace changes should
fix the garbage error messages printed out under certain circumstances.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ktrace/ktrace.c62
-rw-r--r--usr.bin/ktrace/subr.c6
2 files changed, 38 insertions, 30 deletions
diff --git a/usr.bin/ktrace/ktrace.c b/usr.bin/ktrace/ktrace.c
index e584265..38577f3 100644
--- a/usr.bin/ktrace/ktrace.c
+++ b/usr.bin/ktrace/ktrace.c
@@ -38,7 +38,11 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)ktrace.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
#include <sys/param.h>
@@ -48,15 +52,15 @@ static char sccsid[] = "@(#)ktrace.c 8.1 (Berkeley) 6/6/93";
#include <sys/errno.h>
#include <sys/uio.h>
#include <sys/ktrace.h>
+
+#include <err.h>
#include <stdio.h>
-#include <signal.h>
+#include <unistd.h>
+
#include "ktrace.h"
-void noktrace() {
- (void)fprintf(stderr, "ktrace: ktrace not enabled in kernel,to use ktrace\n");
- (void)fprintf(stderr, "you need to add a line \"options KTRACE\" to your kernel\n");
- exit(1);
-}
+void no_ktrace __P((int));
+void usage __P((void));
main(argc, argv)
int argc;
@@ -72,9 +76,6 @@ main(argc, argv)
append = ops = pidset = inherit = 0;
trpoints = DEF_POINTS;
tracefile = DEF_TRACEFILE;
- /* set up a signal handler for SIGSYS, this indicates that ktrace
- is not enabled in the kernel */
- signal(SIGSYS, noktrace);
while ((ch = getopt(argc,argv,"aCcdf:g:ip:t:")) != EOF)
switch((char)ch) {
case 'a':
@@ -107,8 +108,7 @@ main(argc, argv)
case 't':
trpoints = getpoints(optarg);
if (trpoints < 0) {
- (void)fprintf(stderr,
- "ktrace: unknown facility in %s\n", optarg);
+ warnx("unknown facility in %s", optarg);
usage();
}
break;
@@ -117,13 +117,14 @@ main(argc, argv)
}
argv += optind;
argc -= optind;
-
+
if (pidset && *argv || !pidset && !*argv)
usage();
-
+
if (inherit)
trpoints |= KTRFAC_INHERIT;
+ (void)signal(SIGSYS, no_ktrace);
if (clear != NOTSET) {
if (clear == CLEARALL) {
ops = KTROP_CLEAR | KTRFLAG_DESCEND;
@@ -133,24 +134,23 @@ main(argc, argv)
ops |= pid ? KTROP_CLEAR : KTROP_CLEARFILE;
if (ktrace(tracefile, ops, trpoints, pid) < 0)
- error(tracefile);
+ err(1, tracefile);
exit(0);
}
if ((fd = open(tracefile, O_CREAT | O_WRONLY | (append ? 0 : O_TRUNC),
DEFFILEMODE)) < 0)
- error(tracefile);
+ err(1, tracefile);
(void)close(fd);
- if (*argv) {
+ if (*argv) {
if (ktrace(tracefile, ops, trpoints, getpid()) < 0)
- error();
+ err(1, tracefile);
execvp(argv[0], &argv[0]);
- error(argv[0]);
- exit(1);
+ err(1, "exec of '%s' failed", argv[0]);
}
else if (ktrace(tracefile, ops, trpoints, pid) < 0)
- error(tracefile);
+ err(1, tracefile);
exit(0);
}
@@ -160,27 +160,29 @@ rpid(p)
static int first;
if (first++) {
- (void)fprintf(stderr,
- "ktrace: only one -g or -p flag is permitted.\n");
+ warnx("only one -g or -p flag is permitted.");
usage();
}
if (!*p) {
- (void)fprintf(stderr, "ktrace: illegal process id.\n");
+ warnx("illegal process id.");
usage();
}
return(atoi(p));
}
-error(name)
- char *name;
-{
- (void)fprintf(stderr, "ktrace: %s: %s.\n", name, strerror(errno));
- exit(1);
-}
-
+void
usage()
{
(void)fprintf(stderr,
"usage:\tktrace [-aCcid] [-f trfile] [-g pgid] [-p pid] [-t [acgn]\n\tktrace [-aCcid] [-f trfile] [-t [acgn] command\n");
exit(1);
}
+
+void
+no_ktrace(sig)
+ int sig;
+{
+ (void)fprintf(stderr,
+"error:\tktrace() system call not supported in the running kernel\n\tre-compile kernel with 'options KTRACE'\n");
+ exit(1);
+}
diff --git a/usr.bin/ktrace/subr.c b/usr.bin/ktrace/subr.c
index 6076c24..5698b65 100644
--- a/usr.bin/ktrace/subr.c
+++ b/usr.bin/ktrace/subr.c
@@ -32,7 +32,11 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
#include <sys/param.h>
@@ -41,7 +45,9 @@ static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 6/6/93";
#include <sys/proc.h>
#include <sys/time.h>
#include <sys/ktrace.h>
+
#include <stdio.h>
+
#include "ktrace.h"
getpoints(s)
OpenPOWER on IntegriCloud