2
3
4
5
6
7
8
11
12
13
14
15
16
17
18
35
36
37
38
39
40
44 sa.sa_handler = SIG_DFL;
45 sigemptyset(&sa.sa_mask);
46 sa.sa_flags = SA_RESTART;
47 sigaction(SIGINT, &sa,
nullptr);
48 sigaction(SIGTERM, &sa,
nullptr);
49 sigaction(SIGQUIT, &sa,
nullptr);
50 sigaction(SIGUSR1, &sa,
nullptr);
51 sa.sa_flags = SA_SIGINFO;
52 sigaction(SIGSEGV, &sa,
nullptr);
55
56
57
58
59
60
64 memset(&sa, 0,
sizeof(sa));
66 sigemptyset(&sa.sa_mask);
67 sa.sa_flags = SA_RESTART;
68 if (sigaction(SIGINT, &sa,
nullptr) == -1) {
72 if (sigaction(SIGTERM, &sa,
nullptr) == -1) {
76 if (sigaction(SIGQUIT, &sa,
nullptr) == -1) {
80 if (sigaction(SIGUSR1, &sa,
nullptr) == -1) {
84 sa.sa_flags = SA_SIGINFO;
85 if (sigaction(SIGSEGV, &sa,
nullptr) == -1) {
91
92
93
107 char *msg1 =
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
108 write(STDERR_FILENO, msg1, strlen(msg1));
109 char *msg2 =
"SIGSEGV - Segmentation fault - Stack trace\n\n";
110 write(STDERR_FILENO, msg2, strlen(msg2));
115 symbols = backtrace_symbols(addrlist, frames);
116 if (symbols ==
nullptr) {
120 for (
int i = 0; i < frames; i++) {
123 write(STDERR_FILENO, buf, strlen(buf));
126 msg2 =
_(
"\nSIGSEGV Segmentation fault - Writing core to file\n\n");
127 write(STDERR_FILENO, msg2, strlen(msg2));
129 sa.sa_handler = SIG_DFL;
130 sigemptyset(&sa.sa_mask);
132 sigaction(SIGSEGV, &sa, NULL);
133 kill(getpid(), SIGSEGV);
143
144
145
172 sprintf(em0, _(
"Caught signal %d", sig_num));
volatile sig_atomic_t sig_received
bool handle_signal(sig_atomic_t)
void ui_abend(int ec, char *s)
Convert multibyte string to complex character array.
struct termios shell_tioctl
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
bool set_sane_tioctl(struct termios *)
set_sane_tioctl() - set terminal to sane settings for C-MENU
bool restore_shell_tioctl()
restore_shell_tioctl() - restore shell terminal settings
void sig_dfl_mode()
Set signal handlers to default behavior.
void signal_handler(int)
Signal handler for interrupt signals.
void sig_prog_mode()
Set up signal handlers for interrupt signals.