NeoMutt  2024-12-12-14-g7b49f7
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
signal2.h
Go to the documentation of this file.
1
23#ifndef MUTT_MUTT_SIGNAL2_H
24#define MUTT_MUTT_SIGNAL2_H
25
26#include "config.h"
27#include <signal.h>
28#include <stdbool.h>
29
30#ifdef USE_DEBUG_BACKTRACE
31void show_backtrace(void);
32#else
33static inline void show_backtrace(void) {} // LCOV_EXCL_LINE
34#endif
35
36extern volatile sig_atomic_t SigInt;
37extern volatile sig_atomic_t SigWinch;
38
46typedef void (*sig_handler_t)(int sig);
47
48void assertion_dump(const char *file, int line, const char *func, const char *cond);
49
50#ifndef NDEBUG
51#if __GNUC__
52#define ASSERT_STOP __builtin_trap()
53#elif _MSC_VER
54#define ASSERT_STOP __debugbreak()
55#else
56#define ASSERT_STOP (*(volatile int *) 0 = 0)
57#endif
58#define ASSERT(COND) \
59 do \
60 { \
61 if (!(COND)) \
62 { \
63 assertion_dump(__FILE__, __LINE__, __func__, #COND); \
64 ASSERT_STOP; \
65 } \
66 } while (false);
67#else
68#define ASSERT(COND) \
69 do \
70 { \
71 if (COND) \
72 { \
73 } \
74 } while (false);
75#endif
76
77void mutt_sig_allow_interrupt(bool allow);
78void mutt_sig_block(void);
79void mutt_sig_block_system(void);
80void mutt_sig_empty_handler(int sig);
81void mutt_sig_exit_handler(int sig);
82void mutt_sig_init(sig_handler_t sig_fn, sig_handler_t exit_fn, sig_handler_t segv_fn);
84void mutt_sig_unblock(void);
85void mutt_sig_unblock_system(bool restore);
86
87#endif /* MUTT_MUTT_SIGNAL2_H */
void mutt_sig_init(sig_handler_t sig_fn, sig_handler_t exit_fn, sig_handler_t segv_fn)
Initialise the signal handling.
Definition: signal.c:150
void assertion_dump(const char *file, int line, const char *func, const char *cond)
Dump some debugging info before we stop the program.
Definition: signal.c:346
volatile sig_atomic_t SigWinch
true after SIGWINCH is received
Definition: signal.c:67
void mutt_sig_empty_handler(int sig)
Dummy signal handler.
Definition: signal.c:117
void(* sig_handler_t)(int sig)
Definition: signal2.h:46
void mutt_sig_reset_child_signals(void)
Reset ignored signals back to the default.
Definition: signal.c:321
volatile sig_atomic_t SigInt
true after SIGINT is received
Definition: signal.c:66
void mutt_sig_block_system(void)
Block signals before calling exec()
Definition: signal.c:245
void mutt_sig_block(void)
Block signals during critical operations.
Definition: signal.c:212
void mutt_sig_unblock(void)
Restore previously blocked signals.
Definition: signal.c:230
void mutt_sig_unblock_system(bool restore)
Restore previously blocked signals.
Definition: signal.c:269
static void show_backtrace(void)
Definition: signal2.h:33
void mutt_sig_allow_interrupt(bool allow)
Allow/disallow Ctrl-C (SIGINT)
Definition: signal.c:300
void mutt_sig_exit_handler(int sig)
Notify the user and shutdown gracefully.
Definition: signal.c:125