diff --git a/src/frontend/signal_handler.c b/src/frontend/signal_handler.c index 5219d474d..204d54ab6 100644 --- a/src/frontend/signal_handler.c +++ b/src/frontend/signal_handler.c @@ -89,8 +89,6 @@ ft_sigintr(void) return; /* just return without aborting simulation if ft_setflag = TRUE */ } - ft_sigintr_cleanup(); - /* here we jump to the start of command processing in main() after resetting everything. */ LONGJMP(jbuf, 1); } @@ -101,7 +99,6 @@ sigfloat(int sig, int code) { NG_IGNORE(sig); - gr_clean(); fperror("Error", code); rewind(cp_out); (void) signal(SIGFPE, (SIGNAL_FUNCTION) sigfloat); diff --git a/src/main.c b/src/main.c index 8f3934e55..c8db6d0f2 100644 --- a/src/main.c +++ b/src/main.c @@ -624,7 +624,8 @@ app_rl_readlines(void) for (;;) { history_set_pos(history_length); - SETJMP(jbuf, 1); /* Set location to jump to after handling SIGINT (ctrl-C) */ + if (SETJMP(jbuf, 1)) /* Set location to jump to after handling SIGINT (ctrl-C) */ + ft_sigintr_cleanup(); line = readline(prompt()); @@ -1067,6 +1068,7 @@ main(int argc, char **argv) /* To catch interrupts during .spiceinit... */ if (SETJMP(jbuf, 1)) { + ft_sigintr_cleanup(); fprintf(cp_err, "Warning: error executing .spiceinit.\n"); } else { @@ -1105,6 +1107,7 @@ main(int argc, char **argv) if (SETJMP(jbuf, 1)) { + ft_sigintr_cleanup(); fprintf(cp_err, "Warning: error executing during ngspice startup.\n"); } else { @@ -1245,8 +1248,10 @@ main(int argc, char **argv) /* If we get back here in batch mode then something is wrong, * so exit. */ - if (SETJMP(jbuf, 1)) + if (SETJMP(jbuf, 1)) { + ft_sigintr_cleanup(); sp_shutdown(EXIT_BAD); + } if (ft_servermode) { @@ -1293,6 +1298,7 @@ main(int argc, char **argv) if (SETJMP(jbuf, 1)) { + ft_sigintr_cleanup(); fprintf(cp_err, "Warning: error executing during ft_loadfile().\n"); } else { @@ -1320,5 +1326,7 @@ main(int argc, char **argv) /* enter the command processing loop */ cp_interactive = TRUE; app_rl_readlines(); + } else { + ft_sigintr_cleanup(); } } diff --git a/src/sharedspice.c b/src/sharedspice.c index af393b382..5cf7c40df 100644 --- a/src/sharedspice.c +++ b/src/sharedspice.c @@ -422,6 +422,7 @@ runc(char* command) #if 1 //!defined(_MSC_VER) /*&& !defined(__MINGW32__) */ oldHandler = signal(SIGINT, (SIGNAL_FUNCTION) ft_sigintr); if (SETJMP(jbuf, 1) != 0) { + ft_sigintr_cleanup(); signal(SIGINT, oldHandler); return 0; } @@ -605,6 +606,7 @@ ngSpice_Init(SendChar* printfcn, SendStat* statusfcn, ControlledExit* ngspiceexi /* To catch interrupts during .spiceinit... */ old_sigint = signal(SIGINT, (SIGNAL_FUNCTION) ft_sigintr); if (SETJMP(jbuf, 1) == 1) { + ft_sigintr_cleanup(); fprintf(cp_err, "Warning: error executing .spiceinit.\n"); goto bot; } diff --git a/src/tclspice.c b/src/tclspice.c index c7df5d8d7..505115337 100644 --- a/src/tclspice.c +++ b/src/tclspice.c @@ -768,6 +768,7 @@ _run(int argc, char **argv) #ifndef _MSC_VER_ oldHandler = signal(SIGINT, (SIGNAL_FUNCTION) ft_sigintr); if (SETJMP(jbuf, 1) != 0) { + ft_sigintr_cleanup(); signal(SIGINT, oldHandler); return TCL_OK; } @@ -2517,6 +2518,7 @@ Spice_Init(Tcl_Interp *interp) /* To catch interrupts during .spiceinit... */ old_sigint = signal(SIGINT, (SIGNAL_FUNCTION) ft_sigintr); if (SETJMP(jbuf, 1) == 1) { + ft_sigintr_cleanup(); fprintf(cp_err, "Warning: error executing .spiceinit.\n"); goto bot; }