execute ft_sigintr_cleanup() outside of the signal handler
to avoid execution of non-reentrant functions
This commit is contained in:
parent
1cf3dc81bb
commit
9d223d6778
|
|
@ -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);
|
||||
|
|
|
|||
12
src/main.c
12
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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue