]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/event-top.c
[gdb/cli] Handle pending ^C after rl_callback_read_char for readline 7
[thirdparty/binutils-gdb.git] / gdb / event-top.c
index 193ea5363ffc429d86aa6b5768a32ab57d6e7647..005ef4b7054d46f3a5920e0ddb8d2fe233d738df 100644 (file)
@@ -137,6 +137,9 @@ static struct async_signal_handler *async_sigterm_token;
    character is processed.  */
 void (*after_char_processing_hook) (void);
 \f
+#if RL_VERSION_MAJOR == 7
+EXTERN_C void _rl_signal_handler (int);
+#endif
 
 /* Wrapper function for calling into the readline library.  This takes
    care of a couple things:
@@ -203,8 +206,14 @@ gdb_rl_callback_read_char_wrapper_noexcept () noexcept
           pending signal.  I'm not sure if that's possible, but it seems
           better to handle the scenario than to assert.  */
        rl_check_signals ();
+#elif RL_VERSION_MAJOR == 7
+      /* Unfortunately, rl_check_signals is not available.  Use private
+        function _rl_signal_handler instead.  */
+
+      while (rl_pending_signal () != 0)
+       _rl_signal_handler (rl_pending_signal ());
 #else
-      /* Unfortunately, rl_check_signals is not available.  */
+#error "Readline major version >= 7 expected"
 #endif
       if (after_char_processing_hook)
        (*after_char_processing_hook) ();