1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2021 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 static volatile int release_forking_thread
= 0;
24 static pthread_barrier_t barrier
;
35 pthread_barrier_wait (&barrier
);
37 while (!release_forking_thread
);
39 if (FORK_FUNCTION () == 0)
47 #if defined(MAIN_THREAD_FORKS)
49 #elif defined(OTHER_THREAD_FORKS)
52 # error "MAIN_THREAD_FORKS or OTHER_THREAD_FORKS must be defined"
63 pthread_barrier_init (&barrier
, NULL
, 2);
66 ret
= pthread_create (&thread
, NULL
, thread_func
, NULL
);
69 pthread_barrier_wait (&barrier
);
71 #if defined(MAIN_THREAD_FORKS)
73 #elif defined(OTHER_THREAD_FORKS)
76 # error "MAIN_THREAD_FORKS or OTHER_THREAD_FORKS must be defined"
79 pthread_join (thread
, NULL
);