NeoMutt  2018-07-16 +952-a2da0a
Teaching an old dog new tricks
DOXYGEN
mutt_signal.c File Reference

Signal handling. More...

#include "config.h"
#include <errno.h>
#include <signal.h>
#include "mutt/mutt.h"
#include "globals.h"
#include "mutt_attach.h"
#include "mutt_curses.h"
+ Include dependency graph for mutt_signal.c:

Go to the source code of this file.

Functions

static void curses_signal_handler (int sig)
 Catch signals and relay the info to the main program. More...
 
static void curses_exit_handler (int sig)
 Notify the user and shutdown gracefully. More...
 
void mutt_signal_init (void)
 Initialise the signal handling. More...
 

Variables

static int IsEndwin = 0
 

Detailed Description

Signal handling.

Authors
  • Michael R. Elkins

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file mutt_signal.c.

Function Documentation

static void curses_signal_handler ( int  sig)
static

Catch signals and relay the info to the main program.

Parameters
sigSignal number, e.g. SIGINT

Definition at line 43 of file mutt_signal.c.

44 {
45  int save_errno = errno;
46 
47  switch (sig)
48  {
49  case SIGTSTP: /* user requested a suspend */
50  if (!Suspend)
51  break;
52  IsEndwin = isendwin();
53  curs_set(1);
54  if (!IsEndwin)
55  endwin();
56  kill(0, SIGSTOP);
57  /* fallthrough */
58 
59  case SIGCONT:
60  if (!IsEndwin)
61  refresh();
62  mutt_curs_set(-1);
63  /* We don't receive SIGWINCH when suspended; however, no harm is done by
64  * just assuming we received one, and triggering the 'resize' anyway. */
65  SigWinch = 1;
66  break;
67 
68  case SIGWINCH:
69  SigWinch = 1;
70  break;
71 
72  case SIGINT:
73  SigInt = 1;
74  break;
75  }
76  errno = save_errno;
77 }
#define curs_set(x)
Definition: mutt_curses.h:87
WHERE SIG_ATOMIC_VOLATILE_T SigInt
true after SIGINT is received
Definition: globals.h:90
static int IsEndwin
Definition: mutt_signal.c:37
WHERE SIG_ATOMIC_VOLATILE_T SigWinch
true after SIGWINCH is received
Definition: globals.h:91
WHERE bool Suspend
Config: Allow the user to suspend NeoMutt using &#39;^Z&#39;.
Definition: globals.h:258
#define mutt_curs_set(x)
Definition: mutt_curses.h:93

+ Here is the caller graph for this function:

static void curses_exit_handler ( int  sig)
static

Notify the user and shutdown gracefully.

Parameters
sigSignal number, e.g. SIGINT

Definition at line 83 of file mutt_signal.c.

84 {
85  curs_set(1);
86  endwin(); /* just to be safe */
88  mutt_sig_exit_handler(sig); /* DOES NOT RETURN */
89 }
#define curs_set(x)
Definition: mutt_curses.h:87
void mutt_unlink_temp_attachments(void)
Delete all temporary attachments.
Definition: mutt_attach.c:1176
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:

void mutt_signal_init ( void  )

Initialise the signal handling.

Definition at line 105 of file mutt_signal.c.

106 {
108 
109 #ifdef USE_SLANG_CURSES
110  /* This bit of code is required because of the implementation of
111  * SLcurses_wgetch(). If a signal is received (like SIGWINCH) when we
112  * are in blocking mode, SLsys_getkey() will not return an error unless
113  * a handler function is defined and it returns -1. This is needed so
114  * that if the user resizes the screen while at a prompt, it will just
115  * abort and go back to the main-menu.
116  */
117  SLang_getkey_intr_hook = mutt_intr_hook;
118 #endif
119 }
static void curses_signal_handler(int sig)
Catch signals and relay the info to the main program.
Definition: mutt_signal.c:43
static void curses_exit_handler(int sig)
Notify the user and shutdown gracefully.
Definition: mutt_signal.c:83
void mutt_sig_init(sig_handler_t sig_fn, sig_handler_t exit_fn)
Initialise the signal handling.
Definition: signal.c:87

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

int IsEndwin = 0
static

Definition at line 37 of file mutt_signal.c.