From b5821f6e5e1ec1df914b475e893dd1c4c7f4d1da Mon Sep 17 00:00:00 2001 From: Mikulas Patocka Date: Wed, 9 Apr 2025 19:03:26 +0200 Subject: [PATCH] Add an option "ctrl_c" that can be used to disable Ctrl-C signal handling Add this option, so that the z3 library can be used in programs that do signal handling on their own. Signed-off-by: Mikulas Patocka --- src/params/context_params.cpp | 1 + src/util/scoped_ctrl_c.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/params/context_params.cpp b/src/params/context_params.cpp index a5c907208..702e0898d 100644 --- a/src/params/context_params.cpp +++ b/src/params/context_params.cpp @@ -157,6 +157,7 @@ void context_params::updt_params(params_ref const & p) { void context_params::collect_param_descrs(param_descrs & d) { insert_rlimit(d); insert_timeout(d); + insert_ctrl_c(d); d.insert("well_sorted_check", CPK_BOOL, "type checker", "false"); d.insert("type_check", CPK_BOOL, "type checker (alias for well_sorted_check)", "true"); d.insert("auto_config", CPK_BOOL, "use heuristics to automatically select solver and configure it", "true"); diff --git a/src/util/scoped_ctrl_c.cpp b/src/util/scoped_ctrl_c.cpp index a3f5ee772..2d60787fd 100644 --- a/src/util/scoped_ctrl_c.cpp +++ b/src/util/scoped_ctrl_c.cpp @@ -18,6 +18,7 @@ Revision History: --*/ #include #include "util/scoped_ctrl_c.h" +#include "util/gparams.h" static scoped_ctrl_c * g_obj = nullptr; @@ -41,6 +42,8 @@ scoped_ctrl_c::scoped_ctrl_c(event_handler & eh, bool once, bool enabled): m_once(once), m_enabled(enabled), m_old_scoped_ctrl_c(g_obj) { + if (gparams::get_value("ctrl_c") == "false") + m_enabled = false; if (m_enabled) { g_obj = this; m_old_handler = signal(SIGINT, on_ctrl_c);