On Fri Oct 20 14:34:02 2023 +0000, Alexandre Julliard wrote:
Right now `TerminateThread` potentially crashes the entire process,
which I think is a bit too much of a broken state? Not necessarily, TerminateThread is essentially a useless API. Still, if we can avoid the crashes it's preferable, but I don't think returning from the thread function is an improvement, and having to create an extra thread just for that purpose is ugly.
Fwiw I think the extra thread could be useful for other purposes, and also remove some specific logic from the code.
For instance I believe the mac port needs an extra thread already, as the main thread is used for macOS main loop, having this on Linux too would make it consistent. I could even imagine using the thread on Linux for some similar thing than macOS, for instance for DBus or host input polling.
I also understand that because the main thread does not have its initial stack created by us, we have some specific logic later to set its syscall_frame early and switch the stack to it in `signal_start_thread`, to the contrary to other threads which start from their kernel stack already.