83 digit =
'0' + (n % 10);
85 if (write(STDOUT_FILENO, &
digit, 1) == -1)
99 if (write(STDOUT_FILENO,
"-", 1) == -1)
118 if (write(STDOUT_FILENO, str, strlen(str)) == -1)
144#ifdef HAVE_DECL_SYS_SIGLIST
146#elif (defined(__sun__) && defined(__svr4__))
148#elif (defined(__alpha) && defined(__osf__))
175 struct sigaction act = { 0 };
176 struct sigaction old_act = { 0 };
178 sigemptyset(&act.sa_mask);
180 act.sa_handler = SIG_IGN;
181 sigaction(SIGPIPE, &act, NULL);
184 sigaction(SIGSEGV, &act, &old_act);
188 sigaction(SIGTERM, &act, NULL);
189 sigaction(SIGHUP, &act, NULL);
190 sigaction(SIGQUIT, &act, NULL);
193 sigaddset(&act.sa_mask, SIGTSTP);
200 sigaction(SIGALRM, &act, NULL);
204 act.sa_flags = SA_RESTART;
207 sigaction(SIGCONT, &act, NULL);
208 sigaction(SIGTSTP, &act, NULL);
209 sigaction(SIGINT, &act, NULL);
210 sigaction(SIGWINCH, &act, NULL);
216 sigemptyset(&act.sa_mask);
218 act.sa_flags |= SA_NOCLDSTOP;
219 sigaction(SIGCHLD, &act, NULL);
234 sigaddset(&
Sigset, SIGTERM);
235 sigaddset(&
Sigset, SIGHUP);
236 sigaddset(&
Sigset, SIGTSTP);
237 sigaddset(&
Sigset, SIGINT);
238 sigaddset(&
Sigset, SIGWINCH);
239 sigprocmask(SIG_BLOCK, &
Sigset, 0);
251 sigprocmask(SIG_UNBLOCK, &
Sigset, 0);
266 struct sigaction sa = { 0 };
269 sa.sa_handler = SIG_IGN;
271 sigemptyset(&sa.sa_mask);
290 sigprocmask(SIG_UNBLOCK, &
SigsetSys, NULL);
298 struct sigaction sa = { 0 };
300 sa.sa_handler = SIG_DFL;
301 sigemptyset(&sa.sa_mask);
303 sigaction(SIGQUIT, &sa, NULL);
304 sigaction(SIGINT, &sa, NULL);
318 struct sigaction sa = { 0 };
323 sa.sa_flags |= SA_RESTART;
325 sigaction(SIGINT, &sa, NULL);
339 struct sigaction sa = { 0 };
341 sa.sa_handler = SIG_DFL;
343 sigemptyset(&sa.sa_mask);
346 sigaction(SIGPIPE, &sa, NULL);
350 sigaction(SIGTERM, &sa, NULL);
351 sigaction(SIGTSTP, &sa, NULL);
352 sigaction(SIGCONT, &sa, NULL);
362void assertion_dump(
const char *file,
int line,
const char *func,
const char *cond)
366 printf(
"%s:%d:%s() -- assertion failed (%s)\n", file, line, func, cond);
void show_backtrace(void)
Log the program's call stack.
void(* sig_handler_t)(int sig)
void mutt_sig_init(sig_handler_t sig_fn, sig_handler_t exit_fn, sig_handler_t segv_fn)
Initialise the signal handling.
void assertion_dump(const char *file, int line, const char *func, const char *cond)
Dump some debugging info before we stop the program.
static bool SysSignalsBlocked
true when system signals are blocked, e.g.
static sig_handler_t ExitHandler
Function to handle SIGTERM (15), SIGHUP (1), SIGQUIT (3) signals.
volatile sig_atomic_t SigWinch
true after SIGWINCH is received
static sig_handler_t SigHandler
Function to handle other signals, e.g. SIGINT (2)
static struct sigaction SysOldQuit
Backup of SIGQUIT handler, when mutt_sig_block_system() is called.
void mutt_sig_empty_handler(int sig)
Dummy signal handler.
static sigset_t Sigset
A set of signals used by mutt_sig_block(), mutt_sig_unblock()
void mutt_sig_reset_child_signals(void)
Reset ignored signals back to the default.
static void exit_print_uint(unsigned int n)
AS-safe version of printf("%u", n)
volatile sig_atomic_t SigInt
true after SIGINT is received
sig_handler_t OldSegvHandler
Keep the old SEGV handler, it could have been set by ASAN.
void mutt_sig_block_system(void)
Block signals before calling exec()
void mutt_sig_block(void)
Block signals during critical operations.
void mutt_sig_unblock(void)
Restore previously blocked signals.
static bool SignalsBlocked
true when signals are blocked, e.g.
static void exit_print_int(int n)
AS-safe version of printf("%d", n)
static sig_handler_t SegvHandler
Function to handle SIGSEGV (11) signals.
static sigset_t SigsetSys
A set of signals used by mutt_sig_block_system(), mutt_sig_unblock_system()
void mutt_sig_unblock_system(bool restore)
Restore previously blocked signals.
static struct sigaction SysOldInt
Backup of SIGINT handler, when mutt_sig_block_system() is called.
static void exit_print_string(const char *str)
AS-safe version of printf("%s", str)
void mutt_sig_allow_interrupt(bool allow)
Allow/disallow Ctrl-C (SIGINT)
void mutt_sig_exit_handler(int sig)
Notify the user and shutdown gracefully.