aboutsummaryrefslogtreecommitdiff
path: root/src/abort_handler.c
blob: 8347f3a3e33561064ea3d9d7055c4d17e7d03899 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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);
	}
}