Signal handling. More...
#include "config.h"
#include <stddef.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "message.h"
#include "signal2.h"
Go to the source code of this file.
Functions | |
void | mutt_sig_empty_handler (int sig) |
Dummy signal handler. | |
void | mutt_sig_exit_handler (int sig) |
Notify the user and shutdown gracefully. | |
void | mutt_sig_init (sig_handler_t sig_fn, sig_handler_t exit_fn, sig_handler_t segv_fn) |
Initialise the signal handling. | |
void | mutt_sig_block (void) |
Block signals during critical operations. | |
void | mutt_sig_unblock (void) |
Restore previously blocked signals. | |
void | mutt_sig_block_system (void) |
Block signals before calling exec() | |
void | mutt_sig_unblock_system (bool restore) |
Restore previously blocked signals. | |
void | mutt_sig_allow_interrupt (bool allow) |
Allow/disallow Ctrl-C (SIGINT) | |
Variables | |
static sigset_t | Sigset |
A set of signals used by mutt_sig_block(), mutt_sig_unblock() | |
static sigset_t | SigsetSys |
A set of signals used by mutt_sig_block_system(), mutt_sig_unblock_system() | |
static struct sigaction | SysOldInt |
Backup of SIGINT handler, when mutt_sig_block_system() is called. | |
static struct sigaction | SysOldQuit |
Backup of SIGQUIT handler, when mutt_sig_block_system() is called. | |
static bool | SignalsBlocked |
true when signals are blocked, e.g. | |
static bool | SysSignalsBlocked |
true when system signals are blocked, e.g. | |
static sig_handler_t | SigHandler = mutt_sig_empty_handler |
Function to handle other signals, e.g. SIGINT (2) | |
static sig_handler_t | ExitHandler = mutt_sig_exit_handler |
Function to handle SIGTERM (15), SIGHUP (1), SIGQUIT (3) signals. | |
static sig_handler_t | SegvHandler = mutt_sig_exit_handler |
Function to handle SIGSEGV (11) signals. | |
Signal handling.
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 signal.c.
void mutt_sig_empty_handler | ( | int | sig | ) |
void mutt_sig_exit_handler | ( | int | sig | ) |
Notify the user and shutdown gracefully.
sig | Signal number, e.g. SIGINT |
Definition at line 78 of file signal.c.
void mutt_sig_init | ( | sig_handler_t | sig_fn, |
sig_handler_t | exit_fn, | ||
sig_handler_t | segv_fn | ||
) |
Initialise the signal handling.
sig_fn | Function to handle signals |
exit_fn | Function to call on uncaught signals |
segv_fn | Function to call on a segfault (Segmentation Violation) |
Set up handlers to ignore or catch signals of interest. We use three handlers for the signals we want to catch, ignore, or exit.
Definition at line 101 of file signal.c.
void mutt_sig_block | ( | void | ) |
Block signals during critical operations.
It's important that certain signals don't interfere with critical operations. Call mutt_sig_unblock() to restore the signals' behaviour.
Definition at line 163 of file signal.c.
void mutt_sig_unblock | ( | void | ) |
void mutt_sig_block_system | ( | void | ) |
Block signals before calling exec()
It's important that certain signals don't interfere with the child process. Call mutt_sig_unblock_system() to restore the signals' behaviour.
Definition at line 196 of file signal.c.
void mutt_sig_unblock_system | ( | bool | restore | ) |
Restore previously blocked signals.
restore | If true, restore previous SIGINT, SIGQUIT behaviour |
Definition at line 220 of file signal.c.
void mutt_sig_allow_interrupt | ( | bool | allow | ) |
Allow/disallow Ctrl-C (SIGINT)
allow | True to allow Ctrl-C to interrupt signals |
Allow the user to interrupt some long operations.
Definition at line 251 of file signal.c.
|
static |
A set of signals used by mutt_sig_block(), mutt_sig_unblock()
|
static |
A set of signals used by mutt_sig_block_system(), mutt_sig_unblock_system()
|
static |
Backup of SIGINT handler, when mutt_sig_block_system() is called.
|
static |
Backup of SIGQUIT handler, when mutt_sig_block_system() is called.
|
static |
|
static |
true when system signals are blocked, e.g.
SIGINT, SIGQUIT
|
static |
|
static |
|
static |