From 611ef1c435dd684ef8a31dab609b752e90aa7e80 Mon Sep 17 00:00:00 2001 From: Robert Swiecki Date: Thu, 17 Aug 2023 15:07:51 +0200 Subject: [PATCH] subproc: support CLONE_CLEAR_SIGHAND --- subproc.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/subproc.cc b/subproc.cc index 69442c3..24e8a5a 100644 --- a/subproc.cc +++ b/subproc.cc @@ -552,10 +552,20 @@ pid_t cloneProc(uint64_t flags, int exit_signal) { #if defined(__NR_clone3) struct clone_args ca = {}; - ca.flags = flags; ca.exit_signal = (uint64_t)exit_signal; + ca.flags = flags | CLONE_CLEAR_SIGHAND; pid_t ret = util::syscall(__NR_clone3, (uintptr_t)&ca, sizeof(ca)); + if (ret != -1) { + return ret; + } + + /* + * Now try without CLONE_CLEAR_SIGHAND as it's supported since Linux 5.5, while clone3 + * appeared in Linux 5.3 + */ + ca.flags = flags; + ret = util::syscall(__NR_clone3, (uintptr_t)&ca, sizeof(ca)); if (ret != -1 || errno != ENOSYS) { return ret; }