NeoMutt  2023-03-22-27-g3cb248
Teaching an old dog new tricks
DOXYGEN
Signal Handling API

Prototype for a Signal Handler function. More...

Functions

static void curses_signal_handler (int sig)
 Catch signals and relay the info to the main program - Implements sig_handler_t -. More...
 
static void curses_exit_handler (int sig)
 Notify the user and shutdown gracefully - Implements sig_handler_t -. More...
 
static void curses_segv_handler (int sig)
 Catch a segfault and print a backtrace - Implements sig_handler_t -. More...
 

Detailed Description

Prototype for a Signal Handler function.

Parameters
sigSignal number, e.g. SIGINT

Function Documentation

◆ curses_signal_handler()

static void curses_signal_handler ( int  sig)
static

Catch signals and relay the info to the main program - Implements sig_handler_t -.

Parameters
sigSignal number, e.g. SIGINT

Definition at line 51 of file mutt_signal.c.

52{
53 int save_errno = errno;
55
56 switch (sig)
57 {
58 case SIGTSTP: /* user requested a suspend */
59 {
60 const bool c_suspend = cs_subset_bool(NeoMutt->sub, "suspend");
61 if (!c_suspend)
62 break;
63 IsEndwin = isendwin();
65 if (!IsEndwin)
66 endwin();
67 kill(0, SIGSTOP);
68 }
69 /* fallthrough */
70
71 case SIGCONT:
72 if (!IsEndwin)
73 refresh();
75 /* We don't receive SIGWINCH when suspended; however, no harm is done by
76 * just assuming we received one, and triggering the 'resize' anyway. */
77 SigWinch = true;
78 break;
79
80 case SIGWINCH:
81 SigWinch = true;
82 break;
83
84 case SIGINT:
85 SigInt = true;
86 break;
87 }
88 errno = save_errno;
89}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
SIG_ATOMIC_VOLATILE_T SigWinch
true after SIGWINCH is received
Definition: globals.c:59
SIG_ATOMIC_VOLATILE_T SigInt
true after SIGINT is received
Definition: globals.c:58
enum MuttCursorState mutt_curses_set_cursor(enum MuttCursorState state)
Set the cursor state.
Definition: mutt_curses.c:96
MuttCursorState
Cursor states for mutt_curses_set_cursor()
Definition: mutt_curses.h:52
@ MUTT_CURSOR_VISIBLE
Display a normal cursor.
Definition: mutt_curses.h:54
static int IsEndwin
Definition: mutt_signal.c:45
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ curses_exit_handler()

static void curses_exit_handler ( int  sig)
static

Notify the user and shutdown gracefully - Implements sig_handler_t -.

Parameters
sigSignal number, e.g. SIGTERM

Definition at line 95 of file mutt_signal.c.

96{
98 endwin(); /* just to be safe */
100 mutt_sig_exit_handler(sig); /* DOES NOT RETURN */
101}
void mutt_unlink_temp_attachments(void)
Delete all temporary attachments.
Definition: mutt_attach.c:1318
void mutt_sig_exit_handler(int sig)
Notify the user and shutdown gracefully.
Definition: signal.c:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ curses_segv_handler()

static void curses_segv_handler ( int  sig)
static

Catch a segfault and print a backtrace - Implements sig_handler_t -.

Parameters
sigSignal number, e.g. SIGSEGV

Definition at line 107 of file mutt_signal.c.

108{
110 endwin(); /* just to be safe */
111#ifdef HAVE_LIBUNWIND
113#endif
114#ifdef USE_DEBUG_GRAPHVIZ
115 dump_graphviz("segfault", NULL);
116#endif
117
118 struct sigaction act;
119 sigemptyset(&act.sa_mask);
120 act.sa_flags = 0;
121 act.sa_handler = SIG_DFL;
122 sigaction(sig, &act, NULL);
123 // Re-raise the signal to give outside handlers a chance to deal with it
124 raise(sig);
125}
void show_backtrace(void)
Log the program's call stack.
Definition: backtrace.c:39
void dump_graphviz(const char *title, struct MailboxView *mv)
Definition: graphviz.c:885
+ Here is the call graph for this function:
+ Here is the caller graph for this function: