From 3ba6736f3a2387bd383b458636d745a96d44b398 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Thu, 2 Jul 2020 16:26:39 +0200 Subject: [PATCH] unshare --fork: Ignore SIGINT and SIGTERM in parent --- sys-utils/unshare.c | 7 +++++++ 1 file changed, 7 insertions(+) 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)) -- 2.47.2