Module Name:    src
Committed By:   christos
Date:           Tue Aug 23 10:01:32 UTC 2011

Modified Files:
        src/bin/sh: show.c

Log Message:
- add pid to the trace file so that we don't keep overwriting ourselves
- use va_copy to print the trace arguments so that we don't deplete it for the 
real printf


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/bin/sh/show.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/sh/show.c
diff -u src/bin/sh/show.c:1.27 src/bin/sh/show.c:1.28
--- src/bin/sh/show.c:1.27	Sun Nov 14 14:36:07 2010
+++ src/bin/sh/show.c	Tue Aug 23 06:01:32 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: show.c,v 1.27 2010/11/14 19:36:07 christos Exp $	*/
+/*	$NetBSD: show.c,v 1.28 2011/08/23 10:01:32 christos Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,13 +37,14 @@
 #if 0
 static char sccsid[] = "@(#)show.c	8.3 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: show.c,v 1.27 2010/11/14 19:36:07 christos Exp $");
+__RCSID("$NetBSD: show.c,v 1.28 2011/08/23 10:01:32 christos Exp $");
 #endif
 #endif /* not lint */
 
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 #include "shell.h"
 #include "parser.h"
@@ -297,9 +298,12 @@
 tracev(const char *fmt, va_list va)
 {
 #ifdef DEBUG
+	va_list ap;
 	if (debug != 1 || !tracefile)
 		return;
-	(void) vfprintf(tracefile, fmt, va);
+	va_copy(ap, va);
+	(void) vfprintf(tracefile, fmt, ap);
+	va_end(ap);
 #endif
 }
 
@@ -400,7 +404,7 @@
 		strcat(s, "/trace");
 	}
 #else
-	scopy("./trace", s);
+	snprintf(s, sizeof(s), "./trace.%d", (int)getpid());
 #endif /* not_this_way */
 	if (tracefile) {
 		if (!freopen(s, "a", tracefile)) {

Reply via email to