diff --git a/src/frontend/signal_handler.c b/src/frontend/signal_handler.c index 1c02a6f05..5219d474d 100644 --- a/src/frontend/signal_handler.c +++ b/src/frontend/signal_handler.c @@ -42,6 +42,33 @@ JMP_BUF jbuf; * is TRUE. */ + +/* The purpose of ft_sigintr_cleanup() is to handle all processing of asynchronous + * signals which require user process context. Some kernel services are not + * allowed to be called from asynchronous signal handlers. (e.g. mutexes) + */ + +void +ft_sigintr_cleanup(void) +{ + gr_clean(); /* Clean up plot window */ + + /* sjb - what to do for editline??? + The following are not supported in editline */ +#if defined(HAVE_GNUREADLINE) + /* Clean up readline after catching signals */ + /* One or all of these might be superfluous */ + (void) rl_free_line_state(); + (void) rl_cleanup_after_signal(); + (void) rl_reset_after_signal(); +#endif /* defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE) */ + + /* To restore screen after an interrupt to a plot for instance */ + cp_interactive = TRUE; + cp_resetcontrol(); +} + + /* invoke this function upon keyboard interrupt */ RETSIGTYPE ft_sigintr(void) @@ -62,21 +89,7 @@ ft_sigintr(void) return; /* just return without aborting simulation if ft_setflag = TRUE */ } - gr_clean(); /* Clean up plot window */ - - /* sjb - what to do for editline??? - The following are not supported in editline */ -#if defined(HAVE_GNUREADLINE) - /* Clean up readline after catching signals */ - /* One or all of these might be superfluous */ - (void) rl_free_line_state(); - (void) rl_cleanup_after_signal(); - (void) rl_reset_after_signal(); -#endif /* defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE) */ - - /* To restore screen after an interrupt to a plot for instance */ - cp_interactive = TRUE; - cp_resetcontrol(); + ft_sigintr_cleanup(); /* here we jump to the start of command processing in main() after resetting everything. */ LONGJMP(jbuf, 1); diff --git a/src/frontend/signal_handler.h b/src/frontend/signal_handler.h index 3c189236e..24a4e491c 100644 --- a/src/frontend/signal_handler.h +++ b/src/frontend/signal_handler.h @@ -17,4 +17,6 @@ RETSIGTYPE sig_sys(void); extern JMP_BUF jbuf; +extern void ft_sigintr_cleanup(void); + #endif