3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-09 00:35:47 +00:00

Z3 sources

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2012-10-02 11:35:25 -07:00
parent 3f9edad676
commit e9eab22e5c
1186 changed files with 381859 additions and 0 deletions

58
lib/scoped_ctrl_c.cpp Normal file
View file

@ -0,0 +1,58 @@
/*++
Copyright (c) 2011 Microsoft Corporation
Module Name:
scoped_ctrl_c.cpp
Abstract:
Scoped control-c handler.
Author:
Leonardo de Moura (leonardo) 2011-04-27.
Revision History:
--*/
#include<signal.h>
#include<iostream>
#include"scoped_ctrl_c.h"
scoped_ctrl_c * scoped_ctrl_c::g_obj = 0;
void scoped_ctrl_c::on_ctrl_c(int) {
if (g_obj->m_first) {
g_obj->m_cancel_eh();
if (g_obj->m_once) {
g_obj->m_first = false;
signal(SIGINT, on_ctrl_c); // re-install the handler
}
}
else {
signal(SIGINT, g_obj->m_old_handler);
raise(SIGINT);
}
}
scoped_ctrl_c::scoped_ctrl_c(event_handler & eh, bool once, bool enabled):
m_cancel_eh(eh),
m_first(true),
m_once(once),
m_enabled(enabled),
m_old_scoped_ctrl_c(g_obj) {
if (m_enabled) {
g_obj = this;
m_old_handler = signal(SIGINT, on_ctrl_c);
}
}
scoped_ctrl_c::~scoped_ctrl_c() {
if (m_enabled) {
g_obj = m_old_scoped_ctrl_c;
if (m_old_handler != SIG_ERR) {
signal(SIGINT, m_old_handler);
}
}
}