diff options
Diffstat (limited to 'src/abort_handler.c')
| -rw-r--r-- | src/abort_handler.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/abort_handler.c b/src/abort_handler.c new file mode 100644 index 0000000..8347f3a --- /dev/null +++ b/src/abort_handler.c @@ -0,0 +1,21 @@ +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +static void abort_handler(__attribute__((unused)) int signo) { + fopen("aborted", "w"); +} + +static void __attribute__((constructor)) register_abort_handler(void) +{ + struct sigaction sa; + sa.sa_handler = abort_handler; + sigemptyset(&sa.sa_mask); + + if (sigaction(SIGABRT, &sa, NULL) == -1) { + perror("sigaction"); + exit(1); + } +} + |
