NeoMutt  2021-10-29-43-g6b8931
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;
54 
55  switch (sig)
56  {
57  case SIGTSTP: /* user requested a suspend */
58  {
59  const bool c_suspend = cs_subset_bool(NeoMutt->sub, "suspend");
60  if (!c_suspend)
61  break;
62  IsEndwin = isendwin();
64  if (!IsEndwin)
65  endwin();
66  kill(0, SIGSTOP);
67  }
68  /* fallthrough */
69 
70  case SIGCONT:
71  if (!IsEndwin)
72  refresh();
74  /* We don't receive SIGWINCH when suspended; however, no harm is done by
75  * just assuming we received one, and triggering the 'resize' anyway. */
76  SigWinch = true;
77  break;
78 
79  case SIGWINCH:
80  SigWinch = true;
81  break;
82 
83  case SIGINT:
84  SigInt = true;
85  break;
86  }
87  errno = save_errno;
88 }
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
void mutt_curses_set_cursor(enum MuttCursorState state)
Set the cursor state.
Definition: mutt_curses.c:63
@ MUTT_CURSOR_RESTORE_LAST
Restore the previous cursor state.
Definition: mutt_curses.h:53
@ MUTT_CURSOR_VISIBLE
Display a normal cursor.
Definition: mutt_curses.h:55
SIG_ATOMIC_VOLATILE_T SigWinch
true after SIGWINCH is received
Definition: mutt_globals.h:74
SIG_ATOMIC_VOLATILE_T SigInt
true after SIGINT is received
Definition: mutt_globals.h:73
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 94 of file mutt_signal.c.

95 {
97  endwin(); /* just to be safe */
99  mutt_sig_exit_handler(sig); /* DOES NOT RETURN */
100 }
void mutt_unlink_temp_attachments(void)
Delete all temporary attachments.
Definition: mutt_attach.c:1286
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 106 of file mutt_signal.c.

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