svn commit: r191005 - head/usr.bin/truss

Xin LI delphij at FreeBSD.org
Mon Apr 13 16:23:33 UTC 2009


Author: delphij
Date: Mon Apr 13 16:23:32 2009
New Revision: 191005
URL: http://svn.freebsd.org/changeset/base/191005

Log:
  Don't exit until all truss children were exit.

Modified:
  head/usr.bin/truss/main.c

Modified: head/usr.bin/truss/main.c
==============================================================================
--- head/usr.bin/truss/main.c	Mon Apr 13 16:22:38 2009	(r191004)
+++ head/usr.bin/truss/main.c	Mon Apr 13 16:23:32 2009	(r191005)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copryight 1997 Sean Eric Fagan
  *
  * Redistribution and use in source and binary forms, with or without
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/sysctl.h>
+#include <sys/wait.h>
 
 #include <ctype.h>
 #include <err.h>
@@ -164,6 +165,8 @@ main(int ac, char **av)
 {
 	int c;
 	int i;
+	pid_t childpid;
+	int status;
 	char **command;
 	struct ex_types *funcs;
 	int initial_open;
@@ -288,8 +291,6 @@ START_TRACE:
 
 			if (trussinfo->curthread->in_fork &&
 			    (trussinfo->flags & FOLLOWFORKS)) {
-				int childpid;
-
 				trussinfo->curthread->in_fork = 0;
 				childpid =
 				    funcs->exit_syscall(trussinfo,
@@ -360,6 +361,11 @@ START_TRACE:
 		}
 	} while (trussinfo->pr_why != S_EXIT);
 	fflush(trussinfo->outfile);
-	
+
+	if (trussinfo->flags & FOLLOWFORKS)
+		do {
+			childpid = wait(&status);
+		} while (childpid != -1);
+
 	return (0);
 }


More information about the svn-src-head mailing list