diff options
author | John Baldwin <jhb@FreeBSD.org> | 2023-03-06 16:55:22 -0800 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2023-03-06 16:55:22 -0800 |
commit | 5c1e53c99cf08b55fda078902a7363823e8638cb (patch) | |
tree | f5bc3c2b8c20609e6856c1a65ab128934f8f9ec6 /gdb/testsuite/gdb.threads/execl.c | |
parent | cf622c39abfa8fe1df1a019020a529a81572ca7b (diff) | |
download | binutils-gdb-5c1e53c99cf08b55fda078902a7363823e8638cb.tar.gz |
gdb.threads/execl.c: Ensure all threads are started before execl.
Use a pthread_barrier to ensure all threads are started before
proceeding to the breakpoint where info threads output is checked.
Diffstat (limited to 'gdb/testsuite/gdb.threads/execl.c')
-rw-r--r-- | gdb/testsuite/gdb.threads/execl.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.threads/execl.c b/gdb/testsuite/gdb.threads/execl.c index 8fb42e7e9ed..b9b42a29247 100644 --- a/gdb/testsuite/gdb.threads/execl.c +++ b/gdb/testsuite/gdb.threads/execl.c @@ -26,9 +26,13 @@ #include <string.h> #include <stdlib.h> +static pthread_barrier_t threads_started_barrier; + void * thread_function (void *arg) { + pthread_barrier_wait (&threads_started_barrier); + while (1) sleep (100); return NULL; @@ -41,9 +45,13 @@ main (int argc, char* argv[]) pthread_t thread2; char *new_image; + pthread_barrier_init (&threads_started_barrier, NULL, 3); + pthread_create (&thread1, NULL, thread_function, NULL); pthread_create (&thread2, NULL, thread_function, NULL); + pthread_barrier_wait (&threads_started_barrier); + new_image = malloc (strlen (argv[0]) + 2); strcpy (new_image, argv[0]); strcat (new_image, "1"); |