On 27/02/16 12:40, Mark Morgan Lloyd wrote:
Is there a way of sending an unambiguous system-level kill signal to a thread? KillThread(ThreadID) doesn't appear to be brutal enough, and I'm unsure of the correct way to access pthread_kill().
You cannot asynchronously kill threads on Unix platforms with the cthreads unit, and even on platforms where you can, you should never do it. All resources held by that thread will leak, and locks it held will never be unlocked.
KillThread() on Unix calls pthread_cancel(), which indicates to the system libraries (or any other libraries that include support for this) that that as soon as they know it is safe to kill the current thread, they should abort it and call its registered cleanup functions.
Since you are in an emulator, the way to solve this is probably to have your own threads regularly check the "terminated" property of the tthread and if it's set (which you can do by calling thread.terminate "on it" from another thread), to clean up everything and abort.
Jonas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal