summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/main.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/main.c b/src/main/main.c
index b96edd4..a1703ce 100644
--- a/src/main/main.c
+++ b/src/main/main.c
@@ -53,6 +53,18 @@ void resized() {
signal(SIGWINCH, resized);
}
+void segfault() {
+ // make an effort to restore the
+ // terminal to its former glory
+ if (display != NULL) {
+ display_clear(display);
+ display_destroy(display);
+ }
+
+ printf("Segfault encountered...\n");
+ abort();
+}
+
#define INVALID_WATCH -1
struct watched_file {
uint32_t watch_id;
@@ -156,6 +168,7 @@ int main(int argc, char *argv[]) {
setlocale(LC_ALL, "");
signal(SIGTERM, terminate);
+ signal(SIGSEGV, segfault);
struct commands commands = command_registry_create(32);