From: Daan De Meyer Date: Thu, 2 Jul 2020 14:26:39 +0000 (+0200) Subject: unshare --fork: Ignore SIGINT and SIGTERM in parent X-Git-Tag: v2.36-rc2~17^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3ba6736f3a2387bd383b458636d745a96d44b398;p=thirdparty%2Futil-linux.git unshare --fork: Ignore SIGINT and SIGTERM in parent --- diff --git a/sys-utils/unshare.c b/sys-utils/unshare.c index ed2eb31e80..47c468d79a 100644 --- a/sys-utils/unshare.c +++ b/sys-utils/unshare.c @@ -555,6 +555,9 @@ int main(int argc, char *argv[]) settime(monotonic, CLOCK_MONOTONIC); if (forkit) { + signal(SIGINT, SIG_IGN); + signal(SIGTERM, SIG_IGN); + /* force child forking before mountspace binding * so pid_for_children is populated */ pid = fork(); @@ -602,6 +605,10 @@ int main(int argc, char *argv[]) if (pid) { if (waitpid(pid, &status, 0) == -1) err(EXIT_FAILURE, _("waitpid failed")); + + signal(SIGINT, SIG_DFL); + signal(SIGTERM, SIG_DFL); + if (WIFEXITED(status)) return WEXITSTATUS(status); if (WIFSIGNALED(status))