Luna/apps/signal-test.cpp
2023-07-10 20:49:22 +02:00

26 lines
418 B
C++

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