pthread_kill, just like kill, is for sending signal to processes. What is more it seems to specifically not be capable of killing an individual pthread, only directing a signal to be received on a specific thread.
The only way a thread can be killed is if vulunarily exits, and sending a signal to a thread is just one way to ask it to exit. If one actually send SIGKILL to a thread it will bring down the entire process, not that just thread.
See https://stackoverflow.com/questions/34258271/pthread-kill-kills-not-just-a-thread-but-the-whole-program for some discussion of this.
We could make a fake implementation of pthread_kill but we would only be able to deliver signals to threads that yield in some way and not busy-looping. It seems that we can really only support cooperative receiving of signal which means we probably can't do better than pthread_cancel if we want to try to bring down a running thread.
What is more the current test for pthread_kill is currently disabled on chrome because it causes the tab to hang (i.e. worker.terminate() simply doesn't work for busy-looping threads). See:
|
@no_chrome('pthread_kill hangs chrome renderer, and keep subsequent tests from passing') |
pthread_kill, just likekill, is for sending signal to processes. What is more it seems to specifically not be capable of killing an individual pthread, only directing a signal to be received on a specific thread.The only way a thread can be killed is if vulunarily exits, and sending a signal to a thread is just one way to ask it to exit. If one actually send
SIGKILLto a thread it will bring down the entire process, not that just thread.See https://stackoverflow.com/questions/34258271/pthread-kill-kills-not-just-a-thread-but-the-whole-program for some discussion of this.
We could make a fake implementation of
pthread_killbut we would only be able to deliver signals to threads that yield in some way and not busy-looping. It seems that we can really only support cooperative receiving of signal which means we probably can't do better thanpthread_cancelif we want to try to bring down a running thread.What is more the current test for pthread_kill is currently disabled on chrome because it causes the tab to hang (i.e. worker.terminate() simply doesn't work for busy-looping threads). See:
emscripten/tests/test_browser.py
Line 3860 in 7c8be3d