I’m using ncurses and whenever I get a segfault, ncurses doesn’t properly release control of the terminal (because endwin() was never called). I set up a signal handler:
void handler(int signum) {
endwin();
exit(EXIT_FAILURE);
}
but the problem with this is that the segfault is ignored, as opposed to delayed until after endwin(). I’m fairly new to C++; can segfaults be caught like exceptions, so that I could have a finally block? Or is there someway to resend the segfault from inside the handler?
Segfault is undefined behavior. You must find it and fix it. Don’t worry about ncurses not releasing the terminal, and find and fix the bug.