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.
{
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. */
{
safe_print(STDERR_FILENO, "cvc5 interrupted by user.\n");
print_statistics();
- abort();
+ signal(sig, SIG_DFL);
+ raise(sig);
}
#ifdef HAVE_SIGALTSTACK
if (!segvSpin)
{
print_statistics();
- abort();
+ signal(sig, SIG_DFL);
+ raise(sig);
}
else
{
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 */
if (!segvSpin)
{
print_statistics();
- abort();
+ signal(sig, SIG_DFL);
+ raise(sig);
}
else
{
#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 */
}