parent
36dac58380
commit
5e99a7bbbf
|
@ -476,6 +476,7 @@ void factor_vm::factorbug_usage(bool advanced_p)
|
||||||
static void exit_fep(factor_vm *vm)
|
static void exit_fep(factor_vm *vm)
|
||||||
{
|
{
|
||||||
vm->unlock_console();
|
vm->unlock_console();
|
||||||
|
vm->handle_ctrl_c();
|
||||||
vm->fep_p = false;
|
vm->fep_p = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,6 +499,7 @@ void factor_vm::factorbug()
|
||||||
// that pumps the console is still running concurrently. We lock a mutex so
|
// that pumps the console is still running concurrently. We lock a mutex so
|
||||||
// the thread will take a break and give us exclusive access to stdin.
|
// the thread will take a break and give us exclusive access to stdin.
|
||||||
lock_console();
|
lock_console();
|
||||||
|
ignore_ctrl_c();
|
||||||
|
|
||||||
if (!fep_help_was_shown) {
|
if (!fep_help_was_shown) {
|
||||||
factorbug_usage(false);
|
factorbug_usage(false);
|
||||||
|
|
|
@ -318,7 +318,6 @@ void factor_vm::unix_init_signals()
|
||||||
struct sigaction memory_sigaction;
|
struct sigaction memory_sigaction;
|
||||||
struct sigaction synchronous_sigaction;
|
struct sigaction synchronous_sigaction;
|
||||||
struct sigaction enqueue_sigaction;
|
struct sigaction enqueue_sigaction;
|
||||||
struct sigaction fep_sigaction;
|
|
||||||
struct sigaction sample_sigaction;
|
struct sigaction sample_sigaction;
|
||||||
struct sigaction fpe_sigaction;
|
struct sigaction fpe_sigaction;
|
||||||
struct sigaction ignore_sigaction;
|
struct sigaction ignore_sigaction;
|
||||||
|
@ -347,8 +346,7 @@ void factor_vm::unix_init_signals()
|
||||||
sigaction_safe(SIGINFO,&enqueue_sigaction,NULL);
|
sigaction_safe(SIGINFO,&enqueue_sigaction,NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
init_sigaction_with_handler(&fep_sigaction, fep_signal_handler);
|
handle_ctrl_c();
|
||||||
sigaction_safe(SIGINT,&fep_sigaction,NULL);
|
|
||||||
|
|
||||||
init_sigaction_with_handler(&sample_sigaction, sample_signal_handler);
|
init_sigaction_with_handler(&sample_sigaction, sample_signal_handler);
|
||||||
sigaction_safe(SIGALRM,&sample_sigaction,NULL);
|
sigaction_safe(SIGALRM,&sample_sigaction,NULL);
|
||||||
|
@ -528,6 +526,23 @@ void factor_vm::unlock_console()
|
||||||
pthread_mutex_unlock(&stdin_mutex);
|
pthread_mutex_unlock(&stdin_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void factor_vm::ignore_ctrl_c()
|
||||||
|
{
|
||||||
|
sig_t ret;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ret = signal(SIGINT, SIG_DFL);
|
||||||
|
}
|
||||||
|
while(ret == SIG_ERR && errno == EINTR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void factor_vm::handle_ctrl_c()
|
||||||
|
{
|
||||||
|
struct sigaction fep_sigaction;
|
||||||
|
init_sigaction_with_handler(&fep_sigaction, fep_signal_handler);
|
||||||
|
sigaction_safe(SIGINT,&fep_sigaction,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void factor_vm::abort()
|
void factor_vm::abort()
|
||||||
{
|
{
|
||||||
sig_t ret;
|
sig_t ret;
|
||||||
|
|
|
@ -305,6 +305,16 @@ static BOOL WINAPI ctrl_handler(DWORD dwCtrlType)
|
||||||
}
|
}
|
||||||
|
|
||||||
void factor_vm::open_console()
|
void factor_vm::open_console()
|
||||||
|
{
|
||||||
|
handle_ctrl_c();
|
||||||
|
}
|
||||||
|
|
||||||
|
void factor_vm::ignore_ctrl_c()
|
||||||
|
{
|
||||||
|
SetConsoleCtrlHandler(factor::ctrl_handler, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void factor_vm::handle_ctrl_c()
|
||||||
{
|
{
|
||||||
SetConsoleCtrlHandler(factor::ctrl_handler, TRUE);
|
SetConsoleCtrlHandler(factor::ctrl_handler, TRUE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -736,6 +736,8 @@ struct factor_vm
|
||||||
static void close_console();
|
static void close_console();
|
||||||
static void lock_console();
|
static void lock_console();
|
||||||
static void unlock_console();
|
static void unlock_console();
|
||||||
|
static void ignore_ctrl_c();
|
||||||
|
static void handle_ctrl_c();
|
||||||
static void abort();
|
static void abort();
|
||||||
static void exit();
|
static void exit();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue