Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/ktrace Two tweaks:



details:   https://anonhg.NetBSD.org/src/rev/72eb74ee19f5
branches:  trunk
changeset: 486628:72eb74ee19f5
user:      sommerfeld <sommerfeld%NetBSD.org@localhost>
date:      Sat May 27 00:45:37 2000 +0000

description:
Two tweaks:
        - For cleaner subprocess traces, malloc something before
spawning, so the syscalls malloc does while initializing don't gunk up
the trace.
        - Increase pipe buffer sizes.

diffstat:

 usr.bin/ktrace/ktrace.c |  19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diffs (59 lines):

diff -r 5e608f81f3e3 -r 72eb74ee19f5 usr.bin/ktrace/ktrace.c
--- a/usr.bin/ktrace/ktrace.c   Sat May 27 00:40:29 2000 +0000
+++ b/usr.bin/ktrace/ktrace.c   Sat May 27 00:45:37 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ktrace.c,v 1.16 2000/04/13 01:27:53 itohy Exp $        */
+/*     $NetBSD: ktrace.c,v 1.17 2000/05/27 00:45:37 sommerfeld Exp $   */
 
 /*-
  * Copyright (c) 1988, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)ktrace.c   8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: ktrace.c,v 1.16 2000/04/13 01:27:53 itohy Exp $");
+__RCSID("$NetBSD: ktrace.c,v 1.17 2000/05/27 00:45:37 sommerfeld Exp $");
 #endif
 #endif /* not lint */
 
@@ -54,6 +54,7 @@
 #include <sys/time.h>
 #include <sys/uio.h>
 #include <sys/ktrace.h>
+#include <sys/socket.h>
 
 #include <err.h>
 #include <stdio.h>
@@ -185,6 +186,12 @@
        setemul(emul_name, 0, 0);
 #endif
 
+       /*
+        * For cleaner traces, initialize malloc now rather
+        * than in a traced subprocess.
+        */
+       free(malloc(1));
+       
        if (inherit)
                trpoints |= KTRFAC_INHERIT;
 
@@ -279,12 +286,18 @@
 
        if (!tracefile || strcmp(tracefile, "-") == 0) {
                int pi[2], dofork, fpid;
-
+               int large = 32768;
+               
                if (pipe(pi) < 0)
                        err(1, "pipe(2)");
                fcntl(pi[0], F_SETFD, FD_CLOEXEC|fcntl(pi[0], F_GETFD, 0));
                fcntl(pi[1], F_SETFD, FD_CLOEXEC|fcntl(pi[1], F_GETFD, 0));
 
+               if (setsockopt(pi[1], SOL_SOCKET, SO_SNDBUF, &large, sizeof(large)) < 0)
+                       err(1, "setsockopt(SO_SNDBUF)");
+               if (setsockopt(pi[0], SOL_SOCKET, SO_RCVBUF, &large, sizeof(large)) < 0)
+                       err(1, "setsockopt(SO_RCVBUF)");
+               
                dofork = (pid == getpid());
 
 #ifdef KTRUSS



Home | Main Index | Thread Index | Old Index