svn commit: r315628 - user/pho/stress2/testcases/tcp

Peter Holm pho at FreeBSD.org
Mon Mar 20 08:58:23 UTC 2017


Author: pho
Date: Mon Mar 20 08:58:22 2017
New Revision: 315628
URL: https://svnweb.freebsd.org/changeset/base/315628

Log:
  Added missing waitpid() and cleanup code while here.
  
  Sponsored by:	Dell EMC Isilon

Modified:
  user/pho/stress2/testcases/tcp/tcp.c

Modified: user/pho/stress2/testcases/tcp/tcp.c
==============================================================================
--- user/pho/stress2/testcases/tcp/tcp.c	Mon Mar 20 08:57:25 2017	(r315627)
+++ user/pho/stress2/testcases/tcp/tcp.c	Mon Mar 20 08:58:22 2017	(r315628)
@@ -30,7 +30,10 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/socket.h>
+#include <sys/wait.h>
+
 #include <netinet/in.h>
+
 #include <err.h>
 #include <errno.h>
 #include <netdb.h>
@@ -143,8 +146,10 @@ writer(void) {
 			if (write(tcpsock, buf, bufsize) < 0) {
 				if (errno == EPIPE)
 					return;
-				err(1, "write(%d), %s:%d", tcpsock,
+				if (errno != ECONNRESET)
+					err(1, "write(%d), %s:%d", tcpsock,
 						__FILE__, __LINE__);
+				_exit(EXIT_SUCCESS);
 			}
 		}
 	}
@@ -171,11 +176,13 @@ test(void)
 
 	if ((pid = fork()) == 0) {
 		writer();
-		exit(EXIT_SUCCESS);
+		_exit(EXIT_SUCCESS);
 
 	} else if (pid > 0) {
 		reader();
 		kill(pid, SIGINT);
+		if (waitpid(pid, NULL, 0) != pid)
+			err(1, "waitpid(%d)", pid);
 	} else
 		err(1, "fork(), %s:%d",  __FILE__, __LINE__);
 


More information about the svn-src-user mailing list