This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Against SIGWINCH annoyance in edit cli cmd

>>>>> "LluÃs" == LluÃs Batlle i Rossell <> 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

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.


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
+#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);
   signal (SIGWINCH, &tui_sigwinch_handler);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]