parent
36dac58380
commit
5e99a7bbbf
|
@ -476,6 +476,7 @@ void factor_vm::factorbug_usage(bool advanced_p)
|
|||
static void exit_fep(factor_vm *vm)
|
||||
{
|
||||
vm->unlock_console();
|
||||
vm->handle_ctrl_c();
|
||||
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
|
||||
// the thread will take a break and give us exclusive access to stdin.
|
||||
lock_console();
|
||||
ignore_ctrl_c();
|
||||
|
||||
if (!fep_help_was_shown) {
|
||||
factorbug_usage(false);
|
||||
|
|
|
@ -318,7 +318,6 @@ void factor_vm::unix_init_signals()
|
|||
struct sigaction memory_sigaction;
|
||||
struct sigaction synchronous_sigaction;
|
||||
struct sigaction enqueue_sigaction;
|
||||
struct sigaction fep_sigaction;
|
||||
struct sigaction sample_sigaction;
|
||||
struct sigaction fpe_sigaction;
|
||||
struct sigaction ignore_sigaction;
|
||||
|
@ -347,8 +346,7 @@ void factor_vm::unix_init_signals()
|
|||
sigaction_safe(SIGINFO,&enqueue_sigaction,NULL);
|
||||
#endif
|
||||
|
||||
init_sigaction_with_handler(&fep_sigaction, fep_signal_handler);
|
||||
sigaction_safe(SIGINT,&fep_sigaction,NULL);
|
||||
handle_ctrl_c();
|
||||
|
||||
init_sigaction_with_handler(&sample_sigaction, sample_signal_handler);
|
||||
sigaction_safe(SIGALRM,&sample_sigaction,NULL);
|
||||
|
@ -528,6 +526,23 @@ void factor_vm::unlock_console()
|
|||
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()
|
||||
{
|
||||
sig_t ret;
|
||||
|
|
|
@ -305,6 +305,16 @@ static BOOL WINAPI ctrl_handler(DWORD dwCtrlType)
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue