Luna/apps/signal-test.cpp
apio 86d14e0d0e
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
kernel+libc: Add the SA_NODEFER and SA_RESETHAND flags for sigaction()
2023-07-10 21:54:04 +02:00

24 lines
390 B
C++

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