From 2ee2f2821b3d0b3779f62eb3b9aa817b844c94fd Mon Sep 17 00:00:00 2001 From: Chris Webb Date: Mon, 4 Dec 2023 18:15:14 +0000 Subject: [PATCH] unshare: don't try to reset the disposition of SIGKILL 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 --- sys-utils/unshare.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys-utils/unshare.c b/sys-utils/unshare.c index 6222c1421c..d46985bf1d 100644 --- a/sys-utils/unshare.c +++ b/sys-utils/unshare.c @@ -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, -- 2.47.2