Luna/apps/signal-test.cpp

26 lines
418 B
C++
Raw Normal View History

2023-07-10 17:46:57 +00:00
#include <signal.h>
#include <stdio.h>
#include <string.h>
2023-07-10 17:46:57 +00:00
void handler(int)
{
puts("I caught a segfault!");
struct sigaction sa;
sa.sa_handler = SIG_DFL;
sigaction(SIGSEGV, &sa, NULL);
2023-07-10 17:46:57 +00:00
}
int main()
{
struct sigaction sa;
sa.sa_handler = handler;
sigaction(SIGSEGV, &sa, NULL);
2023-07-10 17:46:57 +00:00
#pragma GCC diagnostic ignored "-Wnonnull"
char* str = nullptr;
memset(str, 0, 2);
2023-07-10 17:46:57 +00:00
return 0;
}