From db4f78d463feb3de0ad3a8672cceffc6c4e5d8f8 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sun, 27 Dec 2020 15:05:39 -0800 Subject: [PATCH] Unblock signals before executing commands --- native/jni/utils/misc.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/native/jni/utils/misc.cpp b/native/jni/utils/misc.cpp index 8d3ad20bd..f4f6c7fa9 100644 --- a/native/jni/utils/misc.cpp +++ b/native/jni/utils/misc.cpp @@ -2,9 +2,6 @@ #include #include #include -#include -#include -#include #include #include #include @@ -30,10 +27,6 @@ int fork_no_orphan() { int pid = xfork(); if (pid) return pid; - // Unblock all signals - sigset_t block_set; - sigfillset(&block_set); - pthread_sigmask(SIG_UNBLOCK, &block_set, nullptr); prctl(PR_SET_PDEATHSIG, SIGTERM); if (getppid() == 1) exit(1); @@ -96,6 +89,11 @@ int exec_command(exec_t &exec) { return pid; } + // Unblock all signals + sigset_t set; + sigfillset(&set); + pthread_sigmask(SIG_UNBLOCK, &set, nullptr); + if (outfd >= 0) { xdup2(outfd, STDOUT_FILENO); if (exec.err)