diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-06-26 12:42:40 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-06-26 12:04:59 +0000 |
| commit | 880c1ca1d9289d57d785f043306f8b243edf4197 (patch) | |
| tree | 98df2fe2a59bbe9aa61162ba0ea5371ee3bd277e /executor | |
| parent | 551aee64cd4d0daebf60a0c0aed4a4e09a9d39b6 (diff) | |
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.
Diffstat (limited to 'executor')
| -rw-r--r-- | executor/executor_test.h | 11 |
1 files changed, 11 insertions, 0 deletions
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 <sys/mman.h> #include <unistd.h> +#ifdef __linux__ +#include <sys/prctl.h> +#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); |
