Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit de506f73 authored by Michael Ellerman's avatar Michael Ellerman Committed by Benjamin Herrenschmidt
Browse files

selftests/powerpc: Put the test in a separate process group



Allows us to kill the test and any children it has spawned.

Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 0a6121cf
Loading
Loading
Loading
Loading
+8 −2
Original line number Original line Diff line number Diff line
@@ -30,12 +30,15 @@ int run_test(int (test_function)(void), char *name)


	pid = fork();
	pid = fork();
	if (pid == 0) {
	if (pid == 0) {
		setpgid(0, 0);
		exit(test_function());
		exit(test_function());
	} else if (pid == -1) {
	} else if (pid == -1) {
		perror("fork");
		perror("fork");
		return 1;
		return 1;
	}
	}


	setpgid(pid, pid);

	/* Wake us up in timeout seconds */
	/* Wake us up in timeout seconds */
	alarm(TIMEOUT);
	alarm(TIMEOUT);
	terminated = false;
	terminated = false;
@@ -50,17 +53,20 @@ int run_test(int (test_function)(void), char *name)


		if (terminated) {
		if (terminated) {
			printf("!! force killing %s\n", name);
			printf("!! force killing %s\n", name);
			kill(pid, SIGKILL);
			kill(-pid, SIGKILL);
			return 1;
			return 1;
		} else {
		} else {
			printf("!! killing %s\n", name);
			printf("!! killing %s\n", name);
			kill(pid, SIGTERM);
			kill(-pid, SIGTERM);
			terminated = true;
			terminated = true;
			alarm(KILL_TIMEOUT);
			alarm(KILL_TIMEOUT);
			goto wait;
			goto wait;
		}
		}
	}
	}


	/* Kill anything else in the process group that is still running */
	kill(-pid, SIGTERM);

	if (WIFEXITED(status))
	if (WIFEXITED(status))
		status = WEXITSTATUS(status);
		status = WEXITSTATUS(status);
	else {
	else {