80 digit =
'0' + (n % 10);
81 write(STDOUT_FILENO, &
digit, 1);
92 write(STDOUT_FILENO,
"-", 1);
107 write(STDOUT_FILENO, str, strlen(str));
130#ifdef HAVE_DECL_SYS_SIGLIST
132#elif (defined(__sun__) && defined(__svr4__))
134#elif (defined(__alpha) && defined(__osf__))
161 struct sigaction act = { 0 };
163 sigemptyset(&act.sa_mask);
165 act.sa_handler = SIG_IGN;
166 sigaction(SIGPIPE, &act, NULL);
169 sigaction(SIGSEGV, &act, NULL);
172 sigaction(SIGTERM, &act, NULL);
173 sigaction(SIGHUP, &act, NULL);
174 sigaction(SIGQUIT, &act, NULL);
177 sigaddset(&act.sa_mask, SIGTSTP);
184 sigaction(SIGALRM, &act, NULL);
188 act.sa_flags = SA_RESTART;
191 sigaction(SIGCONT, &act, NULL);
192 sigaction(SIGTSTP, &act, NULL);
193 sigaction(SIGINT, &act, NULL);
194 sigaction(SIGWINCH, &act, NULL);
200 sigemptyset(&act.sa_mask);
202 act.sa_flags |= SA_NOCLDSTOP;
203 sigaction(SIGCHLD, &act, NULL);
218 sigaddset(&
Sigset, SIGTERM);
219 sigaddset(&
Sigset, SIGHUP);
220 sigaddset(&
Sigset, SIGTSTP);
221 sigaddset(&
Sigset, SIGINT);
222 sigaddset(&
Sigset, SIGWINCH);
223 sigprocmask(SIG_BLOCK, &
Sigset, 0);
235 sigprocmask(SIG_UNBLOCK, &
Sigset, 0);
250 struct sigaction sa = { 0 };
253 sa.sa_handler = SIG_IGN;
255 sigemptyset(&sa.sa_mask);
274 sigprocmask(SIG_UNBLOCK, &
SigsetSys, NULL);
282 struct sigaction sa = { 0 };
284 sa.sa_handler = SIG_DFL;
285 sigemptyset(&sa.sa_mask);
287 sigaction(SIGQUIT, &sa, NULL);
288 sigaction(SIGINT, &sa, NULL);
302 struct sigaction sa = { 0 };
307 sa.sa_flags |= SA_RESTART;
309 sigaction(SIGINT, &sa, NULL);
323 struct sigaction sa = { 0 };
325 sa.sa_handler = SIG_DFL;
327 sigemptyset(&sa.sa_mask);
330 sigaction(SIGPIPE, &sa, NULL);
334 sigaction(SIGTERM, &sa, NULL);
335 sigaction(SIGTSTP, &sa, NULL);
336 sigaction(SIGCONT, &sa, NULL);
346void assertion_dump(
const char *file,
int line,
const char *func,
const char *cond)
350 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
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.