1251876Speter/* Clean exit of the thread group leader should not break GDB. 2251876Speter 3251876Speter Copyright 2007-2020 Free Software Foundation, Inc. 4251876Speter 5251876Speter This program is free software; you can redistribute it and/or modify 6251876Speter it under the terms of the GNU General Public License as published by 7251876Speter the Free Software Foundation; either version 3 of the License, or 8251876Speter (at your option) any later version. 9251876Speter 10251876Speter This program is distributed in the hope that it will be useful, 11251876Speter but WITHOUT ANY WARRANTY; without even the implied warranty of 12251876Speter MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13251876Speter GNU General Public License for more details. 14251876Speter 15251876Speter You should have received a copy of the GNU General Public License 16251876Speter along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17251876Speter 18251876Speter#include <pthread.h> 19251876Speter#include <assert.h> 20251876Speter#include <unistd.h> 21251876Speter 22251876Speterstatic volatile pthread_t main_thread; 23251876Speter 24251876Speterstatic void * 25251876Speterstart (void *arg) 26251876Speter{ 27251876Speter int i; 28251876Speter 29251876Speter i = pthread_join (main_thread, NULL); 30251876Speter assert (i == 0); 31251876Speter 32251876Speter sleep (10); /* break-here */ 33251876Speter return arg; 34251876Speter} 35251876Speter 36251876Speterint 37251876Spetermain (void) 38251876Speter{ 39251876Speter pthread_t thread; 40251876Speter int i; 41251876Speter 42251876Speter main_thread = pthread_self (); 43251876Speter 44251876Speter i = pthread_create (&thread, NULL, start, NULL); 45251876Speter assert (i == 0); 46251876Speter 47251876Speter pthread_exit (NULL); 48251876Speter /* NOTREACHED */ 49251876Speter return 0; 50251876Speter} 51251876Speter