Signal handling. More...
#include "config.h"
#include <signal.h>
#include <stdbool.h>
Go to the source code of this file.
Macros | |
#define | ASSERT_STOP (*(volatile int *) 0 = 0) |
#define | ASSERT(COND) |
Typedefs | |
typedef void(* | sig_handler_t) (int sig) |
Functions | |
static void | show_backtrace (void) |
void | assertion_dump (const char *file, int line, const char *func, const char *cond) |
Dump some debugging info before we stop the program. | |
void | mutt_sig_allow_interrupt (bool allow) |
Allow/disallow Ctrl-C (SIGINT) | |
void | mutt_sig_block (void) |
Block signals during critical operations. | |
void | mutt_sig_block_system (void) |
Block signals before calling exec() | |
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_reset_child_signals (void) |
Reset ignored signals back to the default. | |
void | mutt_sig_unblock (void) |
Restore previously blocked signals. | |
void | mutt_sig_unblock_system (bool restore) |
Restore previously blocked signals. | |
Variables | |
volatile sig_atomic_t | SigInt |
true after SIGINT is received | |
volatile sig_atomic_t | SigWinch |
true after SIGWINCH is received | |
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 signal2.h.
#define ASSERT | ( | COND | ) |
|
inlinestatic |
void assertion_dump | ( | const char * | file, |
int | line, | ||
const char * | func, | ||
const char * | cond | ||
) |
Dump some debugging info before we stop the program.
file | Source file |
line | Line of source |
func | Function |
cond | Assertion condition |
Definition at line 346 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 300 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 212 of file signal.c.
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 245 of 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 125 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 150 of file signal.c.
void mutt_sig_reset_child_signals | ( | void | ) |
Reset ignored signals back to the default.
See sigaction(2): A child created via fork(2) inherits a copy of its parent's signal dispositions. During an execve(2), the dispositions of handled signals are reset to the default; the dispositions of ignored signals are left unchanged.
Definition at line 321 of file signal.c.
void mutt_sig_unblock | ( | void | ) |
void mutt_sig_unblock_system | ( | bool | restore | ) |
Restore previously blocked signals.
restore | If true, restore previous SIGINT, SIGQUIT behaviour |
Definition at line 269 of file signal.c.
|
extern |