From: Chris Webb Date: Mon, 4 Dec 2023 18:15:14 +0000 (+0000) Subject: unshare: don't try to reset the disposition of SIGKILL X-Git-Tag: v2.40-rc1~138^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2ee2f2821b3d0b3779f62eb3b9aa817b844c94fd;p=thirdparty%2Futil-linux.git 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 --- 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,