test/testlock.c
changeset 2779 4436464c4f51
parent 1895 c121d94672cb
child 3578 0d1b16ee0bca
     1.1 --- a/test/testlock.c	Sat Nov 22 06:59:22 2008 +0000
     1.2 +++ b/test/testlock.c	Mon Nov 24 00:18:42 2008 +0000
     1.3 @@ -44,8 +44,9 @@
     1.4      Uint32 id = SDL_ThreadID();
     1.5      int i;
     1.6      printf("Process %u:  Cleaning up...\n", id == mainthread ? 0 : id);
     1.7 +    doterminate = 1;
     1.8      for (i = 0; i < 6; ++i)
     1.9 -        SDL_KillThread(threads[i]);
    1.10 +        SDL_WaitThread(threads[i], NULL);
    1.11      SDL_DestroyMutex(mutex);
    1.12      exit(sig);
    1.13  }
    1.14 @@ -55,7 +56,7 @@
    1.15  {
    1.16      if (SDL_ThreadID() == mainthread)
    1.17          signal(SIGTERM, closemutex);
    1.18 -    while (1) {
    1.19 +    while (!doterminate) {
    1.20          printf("Process %u ready to work\n", SDL_ThreadID());
    1.21          if (SDL_mutexP(mutex) < 0) {
    1.22              fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError());
    1.23 @@ -70,10 +71,10 @@
    1.24          }
    1.25          /* If this sleep isn't done, then threads may starve */
    1.26          SDL_Delay(10);
    1.27 -        if (SDL_ThreadID() == mainthread && doterminate) {
    1.28 -            printf("Process %u:  raising SIGTERM\n", SDL_ThreadID());
    1.29 -            raise(SIGTERM);
    1.30 -        }
    1.31 +    }
    1.32 +    if (SDL_ThreadID() == mainthread && doterminate) {
    1.33 +        printf("Process %u:  raising SIGTERM\n", SDL_ThreadID());
    1.34 +        raise(SIGTERM);
    1.35      }
    1.36      return (0);
    1.37  }