+2021-04-28 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * extension.c (struct scoped_default_signal): New struct.
+ (scoped_default_sigint): New typedef.
+ (finish_ext_lang_initialization): Make use of
+ scoped_default_sigint.
+
2021-04-28 Andrew Burgess <andrew.burgess@embecosm.com>
* main.c (captured_main_1): Don't pass argument to gdb_init.
return extlang->script_ops->auto_load_enabled (extlang);
}
\f
+
+/* RAII class used to temporarily return SIG to its default handler. */
+
+template<int SIG>
+struct scoped_default_signal
+{
+ scoped_default_signal ()
+ { m_old_sig_handler = signal (SIG, SIG_DFL); }
+
+ ~scoped_default_signal ()
+ { signal (SIG, m_old_sig_handler); }
+
+ DISABLE_COPY_AND_ASSIGN (scoped_default_signal);
+
+private:
+ /* The previous signal handler that needs to be restored. */
+ sighandler_t m_old_sig_handler;
+};
+
+/* Class to temporarily return SIGINT to its default handler. */
+
+using scoped_default_sigint = scoped_default_signal<SIGINT>;
+
/* Functions that iterate over all extension languages.
These only iterate over external extension languages, not including
GDB's own extension/scripting language, unless otherwise indicated. */
{
if (extlang->ops != nullptr
&& extlang->ops->finish_initialization != NULL)
- extlang->ops->finish_initialization (extlang);
+ {
+ scoped_default_sigint set_sigint_to_default_handler;
+ extlang->ops->finish_initialization (extlang);
+ }
}
}