test/testsem.c
changeset 1151 be9c9c8f6d53
parent 0 74212992fb08
child 1439 4d3bb026cd16
     1.1 --- a/test/testsem.c	Wed Sep 28 06:38:22 2005 +0000
     1.2 +++ b/test/testsem.c	Wed Sep 28 11:36:20 2005 +0000
     1.3 @@ -13,6 +13,13 @@
     1.4  static SDL_sem *sem;
     1.5  int alive = 1;
     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 ThreadFunc(void *data)
    1.15  {
    1.16  	while ( alive ) {
    1.17 @@ -39,15 +46,14 @@
    1.18  
    1.19  	if(argc < 2) {
    1.20  		fprintf(stderr,"Usage: %s init_value\n", argv[0]);
    1.21 -		exit(1);
    1.22 +		return(1);
    1.23  	}
    1.24  
    1.25  	/* Load the SDL library */
    1.26  	if ( SDL_Init(0) < 0 ) {
    1.27  		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
    1.28 -		exit(1);
    1.29 +		return(1);
    1.30  	}
    1.31 -	atexit(SDL_Quit);
    1.32  	signal(SIGTERM, killed);
    1.33  	signal(SIGINT, killed);
    1.34  	
    1.35 @@ -72,5 +78,6 @@
    1.36  	printf("Finished waiting for threads\n");
    1.37  
    1.38  	SDL_DestroySemaphore(sem);
    1.39 +	SDL_Quit();
    1.40  	return(0);
    1.41  }