Mercurial > sdl-ios-xcode
diff test/testlock.c @ 1659:14717b52abc0 SDL-1.3
Merge trunk-1.3-3
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 17 May 2006 08:18:28 +0000 |
parents | be9c9c8f6d53 |
children | 782fd950bd46 c121d94672cb |
line wrap: on
line diff
--- a/test/testlock.c Mon May 01 06:58:33 2006 +0000 +++ b/test/testlock.c Wed May 17 08:18:28 2006 +0000 @@ -5,7 +5,6 @@ #include <signal.h> #include <stdio.h> -#include <stdlib.h> #include "SDL.h" #include "SDL_mutex.h" @@ -14,6 +13,7 @@ static SDL_mutex *mutex = NULL; static Uint32 mainthread; static SDL_Thread *threads[6]; +static volatile int doterminate = 0; /* * SDL_Quit() shouldn't be used with atexit() directly because @@ -31,8 +31,8 @@ void terminate(int sig) { - printf("Process %u: raising SIGTERM\n", SDL_ThreadID()); - raise(SIGTERM); + signal(SIGINT, terminate); + doterminate = 1; } void closemutex(int sig) { @@ -44,7 +44,7 @@ SDL_DestroyMutex(mutex); exit(sig); } -int Run(void *data) +int SDLCALL Run(void *data) { if ( SDL_ThreadID() == mainthread ) signal(SIGTERM, closemutex); @@ -63,6 +63,10 @@ } /* If this sleep isn't done, then threads may starve */ SDL_Delay(10); + if (SDL_ThreadID() == mainthread && doterminate) { + printf("Process %u: raising SIGTERM\n", SDL_ThreadID()); + raise(SIGTERM); + } } return(0); }