svn commit: r191861 - stable/7/usr.bin/truss

Xin LI delphij at FreeBSD.org
Wed May 6 22:26:50 UTC 2009


Author: delphij
Date: Wed May  6 22:26:49 2009
New Revision: 191861
URL: http://svn.freebsd.org/changeset/base/191861

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

Modified:
  stable/7/usr.bin/truss/   (props changed)
  stable/7/usr.bin/truss/main.c

Modified: stable/7/usr.bin/truss/main.c
==============================================================================
--- stable/7/usr.bin/truss/main.c	Wed May  6 22:26:04 2009	(r191860)
+++ stable/7/usr.bin/truss/main.c	Wed May  6 22:26:49 2009	(r191861)
@@ -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>
@@ -159,6 +160,8 @@ main(int ac, char **av)
 {
 	int c;
 	int i;
+	pid_t childpid;
+	int status;
 	char **command;
 	struct ex_types *funcs;
 	int initial_open;
@@ -283,8 +286,6 @@ START_TRACE:
 
 			if (trussinfo->curthread->in_fork &&
 			    (trussinfo->flags & FOLLOWFORKS)) {
-				int childpid;
-
 				trussinfo->curthread->in_fork = 0;
 				childpid =
 				    funcs->exit_syscall(trussinfo,
@@ -355,6 +356,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-stable-7 mailing list