test/torturethread.c
changeset 1151 be9c9c8f6d53
parent 0 74212992fb08
child 1154 d93862a3d821
     1.1 --- a/test/torturethread.c	Wed Sep 28 06:38:22 2005 +0000
     1.2 +++ b/test/torturethread.c	Wed Sep 28 11:36:20 2005 +0000
     1.3 @@ -13,6 +13,13 @@
     1.4  
     1.5  static char volatile time_for_threads_to_die[NUMTHREADS];
     1.6  
     1.7 +/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
     1.8 +static void quit(int rc)
     1.9 +{
    1.10 +	SDL_Quit();
    1.11 +	exit(rc);
    1.12 +}
    1.13 +
    1.14  int SubThreadFunc(void *data) {
    1.15  	while(! *(int volatile *)data) {
    1.16  		; /*SDL_Delay(10); /* do nothing */
    1.17 @@ -57,10 +64,8 @@
    1.18  	/* Load the SDL library */
    1.19  	if ( SDL_Init(0) < 0 ) {
    1.20  		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
    1.21 -		exit(1);
    1.22 +		return(1);
    1.23  	}
    1.24 -	atexit(SDL_Quit);
    1.25 -
    1.26  
    1.27  	signal(SIGSEGV, SIG_DFL);
    1.28  	for(i = 0; i < NUMTHREADS; i++) {
    1.29 @@ -70,7 +75,7 @@
    1.30  		if ( threads[i] == NULL ) {
    1.31  			fprintf(stderr,
    1.32  			"Couldn't create thread: %s\n", SDL_GetError());
    1.33 -			exit(1);
    1.34 +			quit(1);
    1.35  		}
    1.36  	}
    1.37  
    1.38 @@ -81,5 +86,6 @@
    1.39  	for(i = NUMTHREADS-1; i >= 0; --i) {
    1.40  		SDL_WaitThread(threads[i], NULL);
    1.41  	}
    1.42 -	return(0);	/* Never reached */
    1.43 +	SDL_Quit();
    1.44 +	return(0);
    1.45  }