blob: 5fbe60353ee36876d79818519b049fb2239038b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "file.h"
#include "debug.h"
static void sigsegv(int sig)
{
FILE *f;
time_t t;
printf("segmentation fault received\n");
f=fopen("crash.txt","a");
setvbuf(f, NULL, _IONBF, 0);
fprintf(f,"segmentation fault received\n");
t=time(NULL);
fprintf(f,"Time: %s", ctime(&t));
file_unmap_all();
fprintf(f,"dumping core\n");
fclose(f);
abort();
}
void
debug_init(void)
{
signal(SIGSEGV, sigsegv);
}
|