Skip to content

Instantly share code, notes, and snippets.

View gadLinux's full-sized avatar

Gonzalo Aguilar Delgado gadLinux

View GitHub Profile
@mortenpi
mortenpi / handle_segfault.c
Last active March 2, 2023 01:41
Recover gracefully from a segmentation fault (SIGSEGV) in C due to invalid pointer.
/*
Credits to:
- https://linux.die.net/man/2/setcontext
- https://stackoverflow.com/questions/8456085/why-cant-i-ignore-sigsegv-signal
*/
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <signal.h>