mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-28 01:50:48 +00:00
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.
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user