[PATCH] Against SIGWINCH annoyance in edit cli cmd

Tom Tromey tromey@redhat.com
Wed Aug 15 16:18:00 GMT 2012


>>>>> "Lluís" == Lluís Batlle i Rossell <viric@viric.name> writes:

Lluís> I wrote this small patch that fixes a very annoying bug I hit
Lluís> often in gdb. To get the annoyance, it only requires to run
Lluís> "edit" in the gdb cli to launch an in-terminal editor, and then
Lluís> resize the terminal. Easy to happen on a tiling wm.

Thanks for the report.

Lluís> I found that the readline code takes out the SIGWINCH handler
Lluís> that has SA_RESTART; then the edit-cmd calls 'waitpid()'
Lluís> careless, and as there is no restart of syscalls, waitpid()
Lluís> unblocks and goes back to the gdb prompt. But only SIGWINCH
Lluís> happened.

I looked into this a little.

It is weird to me that we have so many calls to waitpid and other things
that don't check for EINTR.

I wonder whether tui_initialize_win should just use SA_RESTART.  I think
that would solve your problem and also avoid odd problems in these other
areas.

Could you try this patch?

Maybe your patch is also needed, to deal with other signals where we
can't use SA_RESTART.  I am not sure.

Tom

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index c12f036..245b0ee 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -831,11 +831,12 @@ void
 tui_initialize_win (void)
 {
 #ifdef SIGWINCH
-#ifdef HAVE_SIGACTION
+#if defined (HAVE_SIGACTION) && defined (SA_RESTART)
   struct sigaction old_winch;
 
-  memset (&old_winch, 0, sizeof (old_winch));
+  sigemptyset (&old_winch.sa_mask);
   old_winch.sa_handler = &tui_sigwinch_handler;
+  old_winch.sa_flags = SA_RESTART;
   sigaction (SIGWINCH, &old_winch, NULL);
 #else
   signal (SIGWINCH, &tui_sigwinch_handler);



More information about the Gdb-patches mailing list