From 880c1ca1d9289d57d785f043306f8b243edf4197 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 26 Jun 2024 12:42:40 +0200 Subject: executor: set PR_SET_PDEATHSIG for TestOS Otherwise we may leave orphaned executor process children, which prevent the cleanup of the executor directory. Closes #4920. --- executor/executor_test.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'executor/executor_test.h') diff --git a/executor/executor_test.h b/executor/executor_test.h index 4d23f8162..0644e2d97 100644 --- a/executor/executor_test.h +++ b/executor/executor_test.h @@ -5,11 +5,22 @@ #include #include +#ifdef __linux__ +#include +#endif + static uint64 kernel_text_start = 0xc0dec0dec0000000; static uint64 kernel_text_mask = 0xffffff; static void os_init(int argc, char** argv, void* data, size_t data_size) { +#ifdef __linux__ + prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); + // There's a risk that the parent has exited before we get to call prctl(). + // In that case, let's assume that the child must have been reassigned to PID=1. + if (getppid() == 1) + exitf("the parent process was killed"); +#endif void* got = mmap(data, data_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); if (data != got) failmsg("mmap of data segment failed", "want %p, got %p", data, got); -- cgit mrf-deployment