Module Name:    src
Committed By:   pooka
Date:           Wed Jan 12 11:37:45 UTC 2011

Modified Files:
        src/tests/rump/rumpkern/h_client: h_stresscli.c

Log Message:
Give the stress queen two modes: one which nicely suggests an exit
and another one which keeps moet et chandon in her pretty cabinet.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/rump/rumpkern/h_client/h_stresscli.c

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

Modified files:

Index: src/tests/rump/rumpkern/h_client/h_stresscli.c
diff -u src/tests/rump/rumpkern/h_client/h_stresscli.c:1.6 src/tests/rump/rumpkern/h_client/h_stresscli.c:1.7
--- src/tests/rump/rumpkern/h_client/h_stresscli.c:1.6	Wed Jan 12 11:12:25 2011
+++ src/tests/rump/rumpkern/h_client/h_stresscli.c	Wed Jan 12 11:37:45 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: h_stresscli.c,v 1.6 2011/01/12 11:12:25 pooka Exp $	*/
+/*	$NetBSD: h_stresscli.c,v 1.7 2011/01/12 11:37:45 pooka Exp $	*/
 
 #include <sys/types.h>
 #include <sys/atomic.h>
@@ -69,12 +69,20 @@
 	pid_t apid;
 	int ncli = 0;
 	int i = 0, j;
-	int status;
+	int status, thesig;
 	int rounds;
 
-	if (argc != 2)
+	if (argc != 2 && argc != 3)
 		errx(1, "need roundcount");
 
+	if (argc == 3) {
+		if (strcmp(argv[2], "kill") != 0)
+			errx(1, "optional 3rd param must be kill");
+		thesig = SIGKILL;
+	} else {
+		thesig = SIGUSR1;
+	}
+
 	signal(SIGUSR1, signaali);
 
 	memset(clis, 0, sizeof(clis));
@@ -115,16 +123,25 @@
 		}
 
 		usleep(100000);
-		kill(clis[i], SIGUSR1);
+		kill(clis[i], thesig);
 
 		apid = wait(&status);
 		if (apid != clis[i])
 			errx(1, "wanted pid %d, got %d\n", clis[i], apid);
 		clis[i] = 0;
 		ncli--;
-		if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
-			fprintf(stderr, "child died with 0x%x\n", status);
-			exit(1);
+		if (thesig == SIGUSR1) {
+			if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
+				fprintf(stderr, "child died with 0x%x\n",
+				    status);
+				exit(1);
+			}
+		} else {
+			if (!WIFSIGNALED(status) || WTERMSIG(status) != thesig){
+				fprintf(stderr, "child died with 0x%x\n",
+				    status);
+				exit(1);
+			}
 		}
 	}
 

Reply via email to