From c7342f8b72f8bc2391c660000d4080eb745c6205 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 29 Jun 2022 21:48:18 -0500 Subject: [PATCH] Block signals in exit_signal() so sigatexit() list isn't re-entered. xexit() uses siglongjmp() when not exiting, so should clean itself up. --- lib/lib.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/lib.c b/lib/lib.c index 2807c402..c36a7381 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -888,9 +888,14 @@ void generic_signal(int sig) toys.signal = sig; } +// More or less SIG_DFL that runs our atexit list and can siglongjmp. void exit_signal(int sig) { + sigset_t sigset; + if (sig) toys.exitval = sig|128; + sigfillset(&sigset); + sigprocmask(SIG_BLOCK, &sigset, 0); xexit(); } -- 2.39.2