git: e2c59d8dff4b - main - stress2: Fix process handling error

From: Peter Holm <pho_at_FreeBSD.org>
Date: Mon, 20 Jun 2022 12:37:23 UTC
The branch main has been updated by pho:

URL: https://cgit.FreeBSD.org/src/commit/?id=e2c59d8dff4b3e57fed56410194c8959647b98d8

commit e2c59d8dff4b3e57fed56410194c8959647b98d8
Author:     Peter Holm <pho@FreeBSD.org>
AuthorDate: 2022-06-20 12:35:59 +0000
Commit:     Peter Holm <pho@FreeBSD.org>
CommitDate: 2022-06-20 12:35:59 +0000

    stress2: Fix process handling error
---
 tools/test/stress2/misc/mlockall6.sh | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/test/stress2/misc/mlockall6.sh b/tools/test/stress2/misc/mlockall6.sh
index b83e033736fc..33b20ce3137a 100755
--- a/tools/test/stress2/misc/mlockall6.sh
+++ b/tools/test/stress2/misc/mlockall6.sh
@@ -140,7 +140,7 @@ test2(void)
 	for (i = 0; i < 100000 && share2[R2] == 0; i++)
 		touch();	/* while child is running */
 
-	if (waitpid(pid, &status, 0) == -1)
+	if (waitpid(pid, &status, 0) != pid)
 		err(1, "wait");
 
 	if (status != 0)
@@ -169,7 +169,7 @@ test(void)
 int
 main(void)
 {
-	pid_t pid;
+	pid_t pids[PARALLEL];
 	size_t len;
 	time_t start;
 	int i, s, status;
@@ -183,12 +183,13 @@ main(void)
 	s = 0;
 	while (s == 0 && (time(NULL) - start) < RUNTIME) {
 		for (i = 0; i < PARALLEL; i++) {
-			if ((pid = fork()) == 0)
+			if ((pids[i] = fork()) == 0)
 				test();
 		}
 		atomic_add_int(&share[R0], 1);	/* Start test() runs */
 		for (i = 0; i < PARALLEL; i++) {
-			waitpid(pid, &status, 0);
+			if (waitpid(pids[i], &status, 0) != pids[i])
+				err(1, "wait");
 			if (status != 0) {
 				fprintf(stderr, "FAIL: status = %d\n",
 				    status);