summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGereon Kremer <nafur42@gmail.com>2021-05-12 08:22:52 +0200
committerGitHub <noreply@github.com>2021-05-12 08:22:52 +0200
commitf41d71cbf1946a5ee5a63c062a23c7426ec5e87d (patch)
treef59260e3502307c08168afdfca370f7308cfba0b
parentcd1f1c3f308b67fc4b8f006196e5bc1f366cc10d (diff)
Use signal(sig, SIG_DFL); raise(sig); instead of abort() (#6518)
As discussed in #6484 (and https://www.gnu.org/software/libc/manual/html_node/Termination-in-Handler.html), simply calling std::abort at the end of a custom signal handler seems to be bad practice. As suggested, this PR changes these calls to instead first reset to the default signal handler for the given signal, and then calling it. Fixes #6484.
-rw-r--r--src/main/signal_handlers.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/main/signal_handlers.cpp b/src/main/signal_handlers.cpp
index 503bbc198..d0628e2a7 100644
--- a/src/main/signal_handlers.cpp
+++ b/src/main/signal_handlers.cpp
@@ -85,7 +85,8 @@ void sigterm_handler(int sig, siginfo_t* info, void*)
{
safe_print(STDERR_FILENO, "cvc5 interrupted by SIGTERM.\n");
print_statistics();
- abort();
+ signal(sig, SIG_DFL);
+ raise(sig);
}
/** Handler for SIGINT, i.e., when the user hits control C. */
@@ -93,7 +94,8 @@ void sigint_handler(int sig, siginfo_t* info, void*)
{
safe_print(STDERR_FILENO, "cvc5 interrupted by user.\n");
print_statistics();
- abort();
+ signal(sig, SIG_DFL);
+ raise(sig);
}
#ifdef HAVE_SIGALTSTACK
@@ -126,7 +128,8 @@ void segv_handler(int sig, siginfo_t* info, void* c)
if (!segvSpin)
{
print_statistics();
- abort();
+ signal(sig, SIG_DFL);
+ raise(sig);
}
else
{
@@ -165,7 +168,8 @@ void segv_handler(int sig, siginfo_t* info, void* c)
safe_print(STDERR_FILENO, "Looks like a NULL pointer was dereferenced.\n");
}
print_statistics();
- abort();
+ signal(sig, SIG_DFL);
+ raise(sig);
#endif /* CVC5_DEBUG */
}
#endif /* HAVE_SIGALTSTACK */
@@ -179,7 +183,8 @@ void ill_handler(int sig, siginfo_t* info, void*)
if (!segvSpin)
{
print_statistics();
- abort();
+ signal(sig, SIG_DFL);
+ raise(sig);
}
else
{
@@ -203,7 +208,8 @@ void ill_handler(int sig, siginfo_t* info, void*)
#else /* CVC5_DEBUG */
safe_print(STDERR_FILENO, "cvc5 executed an illegal instruction.\n");
print_statistics();
- abort();
+ signal(sig, SIG_DFL);
+ raise(sig);
#endif /* CVC5_DEBUG */
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback