Skip to contentSkip to conversation

lib/tst_test.c: Bugfix for heartbeat

PATCH New Zhao Gongyi 2 participants 3 messages Apr 13, 2021 – Apr 15, 2021 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/tst_test.c: Bugfix for heartbeat

When main process has been killed, its son process will be reaped by init, and son process will send SIGUSR1 to the init process.

In busybox, send SIGUSR1 to the init process will trig shutdown.

---
v1->v2: add exit(TBROK) after kill

---
 lib/tst_test.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
lib/tst_test.c +10 -0
index 45753d1ca..446887c31 100644
@@ -1156,6 +1156,16 @@ static void heartbeat(void)
 	if (tst_clock_gettime(CLOCK_MONOTONIC, &tst_start_time))
 		tst_res(TWARN | TERRNO, "tst_clock_gettime() failed");
 
+	if (getppid() == 1) {
+		tst_res(TFAIL, "Main test process might have exit!");
+		/*
+		 * We need kill the task group immediately since the
+		 * main process has exit.
+		 */
+		kill(0, SIGKILL);
+		exit(TBROK);
+	}
+
 	kill(getppid(), SIGUSR1);
 }
 

--
2.17.1

#1 lore raw

PATCH 1/1 lib/tst_test.c: Bugfix for heartbeat

Hi!
This should have had v2 in the email subject, please do not forget to add the -v flag when generating/sending patches to git.

Otherwise this looks fine, but let's give peter chance to look at it.

Signature · 2 lines
Cyril Hrubis
[email protected]