@@ -194,6 +194,7 @@ Number WallclockTime()
194194}
195195
196196static bool registered_handler = false ;
197+ static unsigned int abortcountdown_ = std::numeric_limits<unsigned int >::max();
197198static void (*handle_interrupt_)(void ) = NULL;
198199static bool * interrupt_flag_ = NULL ;
199200
@@ -210,26 +211,26 @@ static void sighandler(
210211 {
211212 (*handle_interrupt_)();
212213 }
214+
215+ if ( --abortcountdown_ == 0 )
216+ {
217+ fputs (" Ipopt sighandler: Too many interrupt signals. Forcing termination.\n " , stderr);
218+ exit (1 );
219+ }
213220}
214221
215- /* * register handler for interrupt signals
216- *
217- * On POSIX systems, catches SIGHUP and SIGINT signals.
218- * On Windows, catches SIGTERM, SIGABRT, SIGBREAK, and SIGINT signals.
219- *
220- * @return whether registering the handler was successful
221- * @since 3.14.17
222- */
223222bool RegisterInterruptHandler (
224- void (*handle_interrupt)(void ), /* *< function to call when interrupted by signal, if not NULL */
225- bool* interrupt_flag /* *< variable to set to true when interrupted by signal, if not NULL */
223+ void (*handle_interrupt)(void ),
224+ bool* interrupt_flag,
225+ unsigned int abortlimit
226226)
227227{
228228 if ( registered_handler )
229229 {
230230 return false ;
231231 }
232232 registered_handler = true ;
233+ abortcountdown_ = abortlimit;
233234
234235 handle_interrupt_ = handle_interrupt;
235236 interrupt_flag_ = interrupt_flag;
@@ -260,11 +261,6 @@ bool RegisterInterruptHandler(
260261 return true ;
261262}
262263
263- /* * unregister previously registered handler for interrupt signals
264- *
265- * @return whether registering the handler was successful
266- * @since 3.14.17
267- */
268264bool UnregisterInterruptHandler (void )
269265{
270266 if ( !registered_handler )
0 commit comments