aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.threads/signal-command-handle-nopass.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.threads/signal-command-handle-nopass.c')
-rw-r--r--gdb/testsuite/gdb.threads/signal-command-handle-nopass.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.threads/signal-command-handle-nopass.c b/gdb/testsuite/gdb.threads/signal-command-handle-nopass.c
index 6d82bd6..548d0d3 100644
--- a/gdb/testsuite/gdb.threads/signal-command-handle-nopass.c
+++ b/gdb/testsuite/gdb.threads/signal-command-handle-nopass.c
@@ -21,6 +21,8 @@
#include <pthread.h>
#include <signal.h>
+static pthread_barrier_t barrier;
+
void
handler (int sig)
{
@@ -35,6 +37,13 @@ thread_function (void *arg)
usleep (1);
}
+void *
+thread_function_sync (void *arg)
+{
+ pthread_barrier_wait (&barrier);
+ return thread_function (arg);
+}
+
int
main (void)
{
@@ -42,7 +51,15 @@ main (void)
int i;
signal (SIGUSR1, handler);
- pthread_create (&child_thread, NULL, thread_function, NULL);
+
+ pthread_barrier_init (&barrier, NULL, 2);
+
+ pthread_create (&child_thread, NULL, thread_function_sync, NULL);
+
+ /* Make sure that pthread_create is done once the breakpoint on
+ thread_function triggers. */
+ pthread_barrier_wait (&barrier);
+
pthread_join (child_thread, NULL);
return 0;