[PATCH] Fix PR 12702 - gdb can hang waiting for thread group leader (gdbserver)

Hui Zhu
2013-07-20T10:00:22Z

Hi,

I got a issue with leader-exit.exp will hang with target_board=native-gdbserver.
I found the reason is gdbserver still have this issue. So I post a
patch for gdbserver.

Thanks,
Hui

2013-07-20 Hui Zhu <hui@codesourcery.com>

PR gdb/12702
* linux-low.c (my_waitpid): Check if pid is exiting.

--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -423,6 +423,15 @@ my_waitpid (int pid, int *status, int fl
if (wnohang)
break;

+ /* If just wait PID and it is exiting, sigsuspend will
+ hang. So check before call it. */
+ if (pid > 0 && linux_proc_pid_is_zombie (pid))
+ {
+ *status = 0;
+ ret = pid;
+ break;
+ }
+
if (debug_threads)
fprintf (stderr, "blocking\n");