diff options
Diffstat (limited to 'gdb/testsuite/gdb.threads/signal-command-handle-nopass.c')
-rw-r--r-- | gdb/testsuite/gdb.threads/signal-command-handle-nopass.c | 21 |
1 files changed, 19 insertions, 2 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..fec4176 100644 --- a/gdb/testsuite/gdb.threads/signal-command-handle-nopass.c +++ b/gdb/testsuite/gdb.threads/signal-command-handle-nopass.c @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2014-2024 Free Software Foundation, Inc. + Copyright 2014-2025 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -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; |