Index: src/thread/amigaos/SDL_systhread.c =================================================================== --- src/thread/amigaos/SDL_systhread.c (revision 2879) +++ src/thread/amigaos/SDL_systhread.c (working copy) @@ -156,10 +156,4 @@ Wait(SIGBREAKF_CTRL_F | SIGBREAKF_CTRL_C); } -void -SDL_SYS_KillThread(SDL_Thread * thread) -{ - Signal((struct Task *) thread->handle, SIGBREAKF_CTRL_C); -} - /* vi: set ts=4 sw=4 expandtab: */ Index: src/thread/amigaos/SDL_thread.c =================================================================== --- src/thread/amigaos/SDL_thread.c (revision 2879) +++ src/thread/amigaos/SDL_thread.c (working copy) @@ -282,10 +282,7 @@ void SDL_KillThread(SDL_Thread * thread) { - if (thread) { - SDL_SYS_KillThread(thread); - SDL_WaitThread(thread, NULL); - } + /* This is a no-op in SDL 1.3 and later. */ } /* vi: set ts=4 sw=4 expandtab: */ Index: src/thread/riscos/SDL_systhread.c =================================================================== --- src/thread/riscos/SDL_systhread.c (revision 2879) +++ src/thread/riscos/SDL_systhread.c (working copy) @@ -54,12 +54,6 @@ return; } -void -SDL_SYS_KillThread(SDL_Thread * thread) -{ - return; -} - #else #include @@ -143,15 +137,5 @@ pthread_join(thread->handle, 0); } -void -SDL_SYS_KillThread(SDL_Thread * thread) -{ -#ifdef PTHREAD_CANCEL_ASYNCHRONOUS - pthread_cancel(thread->handle); -#else - pthread_kill(thread->handle, SIGKILL); #endif -} - -#endif /* vi: set ts=4 sw=4 expandtab: */ Index: src/thread/win32/SDL_systhread.c =================================================================== --- src/thread/win32/SDL_systhread.c (revision 2879) +++ src/thread/win32/SDL_systhread.c (working copy) @@ -164,14 +164,4 @@ CloseHandle(thread->handle); } -/* WARNING: This function is really a last resort. - * Threads should be signaled and then exit by themselves. - * TerminateThread() doesn't perform stack and DLL cleanup. - */ -void -SDL_SYS_KillThread(SDL_Thread * thread) -{ - TerminateThread(thread->handle, FALSE); -} - /* vi: set ts=4 sw=4 expandtab: */ Index: src/thread/os2/SDL_systhread.c =================================================================== --- src/thread/os2/SDL_systhread.c (revision 2879) +++ src/thread/os2/SDL_systhread.c (working copy) @@ -102,14 +102,4 @@ DosWaitThread(&tid, DCWW_WAIT); } -/* WARNING: This function is really a last resort. - * Threads should be signaled and then exit by themselves. - * TerminateThread() doesn't perform stack and DLL cleanup. - */ -void -SDL_SYS_KillThread(SDL_Thread * thread) -{ - DosKillThread(thread->handle); -} - /* vi: set ts=4 sw=4 expandtab: */ Index: src/thread/dc/SDL_systhread.c =================================================================== --- src/thread/dc/SDL_systhread.c (revision 2879) +++ src/thread/dc/SDL_systhread.c (working copy) @@ -58,10 +58,4 @@ thd_wait(thread->handle); } -void -SDL_SYS_KillThread(SDL_Thread * thread) -{ - thd_destroy(thread->handle); -} - /* vi: set ts=4 sw=4 expandtab: */ Index: src/thread/epoc/SDL_systhread.cpp =================================================================== --- src/thread/epoc/SDL_systhread.cpp (revision 2879) +++ src/thread/epoc/SDL_systhread.cpp (working copy) @@ -110,15 +110,3 @@ User::WaitForRequest(status); taker.Close(); } - -/* WARNING: This function is really a last resort. - * Threads should be signaled and then exit by themselves. - * TerminateThread() doesn't perform stack and DLL cleanup. - */ -void SDL_SYS_KillThread(SDL_Thread *thread) -{ - RThread rthread; - rthread.SetHandle(thread->handle); - rthread.Kill(0); - rthread.Close(); -} Index: src/thread/pthread/SDL_systhread.c =================================================================== --- src/thread/pthread/SDL_systhread.c (revision 2879) +++ src/thread/pthread/SDL_systhread.c (working copy) @@ -112,17 +112,4 @@ pthread_join(thread->handle, 0); } -void -SDL_SYS_KillThread(SDL_Thread * thread) -{ -#ifdef PTHREAD_CANCEL_ASYNCHRONOUS - pthread_cancel(thread->handle); -#else -#ifdef __FREEBSD__ -#warning For some reason, this doesnt actually kill a thread - FreeBSD 3.2 -#endif - pthread_kill(thread->handle, SIGKILL); -#endif -} - /* vi: set ts=4 sw=4 expandtab: */ Index: src/thread/beos/SDL_systhread.c =================================================================== --- src/thread/beos/SDL_systhread.c (revision 2879) +++ src/thread/beos/SDL_systhread.c (working copy) @@ -98,10 +98,4 @@ wait_for_thread(thread->handle, &the_status); } -void -SDL_SYS_KillThread(SDL_Thread * thread) -{ - kill_thread(thread->handle); -} - /* vi: set ts=4 sw=4 expandtab: */ Index: src/thread/SDL_thread.c =================================================================== --- src/thread/SDL_thread.c (revision 2879) +++ src/thread/SDL_thread.c (working copy) @@ -306,10 +306,7 @@ void SDL_KillThread(SDL_Thread * thread) { - if (thread) { - SDL_SYS_KillThread(thread); - SDL_WaitThread(thread, NULL); - } + /* This is a no-op in SDL 1.3 and later. */ } /* vi: set ts=4 sw=4 expandtab: */ Index: src/thread/irix/SDL_systhread.c =================================================================== --- src/thread/irix/SDL_systhread.c (revision 2879) +++ src/thread/irix/SDL_systhread.c (working copy) @@ -81,11 +81,4 @@ } } -/* WARNING: This may not work for systems with 64-bit pid_t */ -void -SDL_KillThread(SDL_Thread * thread) -{ - kill(thread->handle, SIGKILL); -} - /* vi: set ts=4 sw=4 expandtab: */ Index: src/thread/pth/SDL_systhread.c =================================================================== --- src/thread/pth/SDL_systhread.c (revision 2879) +++ src/thread/pth/SDL_systhread.c (working copy) @@ -101,11 +101,4 @@ pth_join(thread->handle, NULL); } -void -SDL_SYS_KillThread(SDL_Thread * thread) -{ - pth_cancel(thread->handle); - pth_join(thread->handle, NULL); -} - /* vi: set ts=4 sw=4 expandtab: */ Index: src/thread/generic/SDL_systhread.c =================================================================== --- src/thread/generic/SDL_systhread.c (revision 2879) +++ src/thread/generic/SDL_systhread.c (working copy) @@ -51,10 +51,4 @@ return; } -void -SDL_SYS_KillThread(SDL_Thread * thread) -{ - return; -} - /* vi: set ts=4 sw=4 expandtab: */ Index: src/thread/SDL_systhread.h =================================================================== --- src/thread/SDL_systhread.h (revision 2879) +++ src/thread/SDL_systhread.h (working copy) @@ -48,8 +48,5 @@ */ extern void SDL_SYS_WaitThread(SDL_Thread * thread); -/* This function kills the thread and returns */ -extern void SDL_SYS_KillThread(SDL_Thread * thread); - #endif /* _SDL_systhread_h */ /* vi: set ts=4 sw=4 expandtab: */ Index: test/testhread.c =================================================================== --- test/testhread.c (revision 2879) +++ test/testhread.c (working copy) @@ -63,22 +63,12 @@ SDL_WaitThread(thread, NULL); alive = 1; + signal(SIGTERM, killed); thread = SDL_CreateThread(ThreadFunc, "#2"); if (thread == NULL) { fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); quit(1); } - SDL_Delay(5 * 1000); - printf("Killing thread #2\n"); - SDL_KillThread(thread); - - alive = 1; - signal(SIGTERM, killed); - thread = SDL_CreateThread(ThreadFunc, "#3"); - if (thread == NULL) { - fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError()); - quit(1); - } raise(SIGTERM); SDL_Quit(); /* Never reached */ Index: test/testlock.c =================================================================== --- test/testlock.c (revision 2879) +++ test/testlock.c (working copy) @@ -44,8 +44,9 @@ Uint32 id = SDL_ThreadID(); int i; printf("Process %u: Cleaning up...\n", id == mainthread ? 0 : id); + doterminate = 1; for (i = 0; i < 6; ++i) - SDL_KillThread(threads[i]); + SDL_WaitThread(threads[i], NULL); SDL_DestroyMutex(mutex); exit(sig); } @@ -55,7 +56,7 @@ { if (SDL_ThreadID() == mainthread) signal(SIGTERM, closemutex); - while (1) { + while (!doterminate) { printf("Process %u ready to work\n", SDL_ThreadID()); if (SDL_mutexP(mutex) < 0) { fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError()); @@ -70,11 +71,11 @@ } /* 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); - } } + if (SDL_ThreadID() == mainthread && doterminate) { + printf("Process %u: raising SIGTERM\n", SDL_ThreadID()); + raise(SIGTERM); + } return (0); } Index: include/SDL_thread.h =================================================================== --- include/SDL_thread.h (revision 2879) +++ include/SDL_thread.h (working copy) @@ -124,7 +124,12 @@ */ extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread * thread, int *status); -/* Forcefully kill a thread without worrying about its state */ +/* This function is here for binary compatibility with legacy apps, but + in SDL 1.3 and later, it's a no-op. You cannot forcibly kill a thread + in a safe manner on many platforms. You should instead find a way to + alert your thread that it is time to terminate, and then have it gracefully + exit on its own. Do not ever call this function! + */ extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread * thread);