Fix fowllowing problems:

1. If fork()ing, the program is executed twice.
2. If the ktruss(1) output is bufferd, the final output is not flushed
   (because it is executing).

    % ktrace -f - rm >/dev/null
    usage: rm [-dfiPRrW] file ...
    usage: rm [-dfiPRrW] file ...
    % ktruss date | cat
    Fri Jul 23 12:09:45 JST 1999
    Fri Jul 23 12:09:46 JST 1999
    %
This commit is contained in:
itohy 1999-07-23 03:10:49 +00:00
parent 7cd460ef5e
commit 99624b0b6d
1 changed files with 8 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ktrace.c,v 1.10 1999/01/11 22:40:01 kleink Exp $ */ /* $NetBSD: ktrace.c,v 1.11 1999/07/23 03:10:49 itohy Exp $ */
/*- /*-
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1993\n\
#if 0 #if 0
static char sccsid[] = "@(#)ktrace.c 8.2 (Berkeley) 4/28/95"; static char sccsid[] = "@(#)ktrace.c 8.2 (Berkeley) 4/28/95";
#else #else
__RCSID("$NetBSD: ktrace.c,v 1.10 1999/01/11 22:40:01 kleink Exp $"); __RCSID("$NetBSD: ktrace.c,v 1.11 1999/07/23 03:10:49 itohy Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -290,6 +290,12 @@ do_ktrace(tracefile, ops, trpoints, pid)
cnt += n; cnt += n;
} }
} }
#endif
if (!nofork)
#ifdef KTRUSS
exit(0); /* flush stdio needed */
#else
_exit(0);
#endif #endif
return 0; return 0;
} }