]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
unshare: don't try to reset the disposition of SIGKILL
authorChris Webb <chris@arachsys.com>
Mon, 4 Dec 2023 18:15:14 +0000 (18:15 +0000)
committerChris Webb <chris@arachsys.com>
Mon, 4 Dec 2023 18:15:14 +0000 (18:15 +0000)
If the child process is killed with SIGKILL, don't attempt to reset the
disposition of SIGKILL (which can't be caught or ignored anyway) before
self-signalling. This caused a misleading 'sigprocmask unblock failed'
error instead of dying with the same SIGKILL status as the child.

Fixes: https://github.com/util-linux/util-linux/issues/2614
Signed-off-by: Chris Webb <chris@arachsys.com>
sys-utils/unshare.c

index 6222c1421c634c35adbcd9fe0a0f03d940bfb08d..d46985bf1d41d75df17c289d0a33c5ad1d7f4aa7 100644 (file)
@@ -994,8 +994,10 @@ int main(int argc, char *argv[])
 
                        int termsig = WTERMSIG(status);
 
-                       if (signal(termsig, SIG_DFL) == SIG_ERR ||
-                               sigemptyset(&sigset) != 0 ||
+                       if (termsig != SIGKILL && signal(termsig, SIG_DFL) == SIG_ERR)
+                               err(EXIT_FAILURE,
+                                       _("signal handler reset failed"));
+                       if (sigemptyset(&sigset) != 0 ||
                                sigaddset(&sigset, termsig) != 0 ||
                                sigprocmask(SIG_UNBLOCK, &sigset, NULL) != 0)
                                err(EXIT_FAILURE,