Bounded join used at shutdown so a wedged worker can't keep Steam alive. Timeout detaches; the OS reaps at process exit.
| 6568 | // Bounded join used at shutdown so a wedged worker can't keep Steam alive. |
| 6569 | // Timeout detaches; the OS reaps at process exit. |
| 6570 | static bool JoinThreadWithTimeout(std::thread& t, DWORD timeoutMs, const char* name) { |
| 6571 | if (!t.joinable()) return true; |
| 6572 | HANDLE h = static_cast<HANDLE>(t.native_handle()); |
| 6573 | DWORD wait = WaitForSingleObject(h, timeoutMs); |
| 6574 | if (wait == WAIT_OBJECT_0) { |
| 6575 | t.join(); |
| 6576 | return true; |
| 6577 | } |
| 6578 | LOG("Shutdown: %s did not finish within %u ms (wait=%u) -- detaching to unblock shutdown", |
| 6579 | name, timeoutMs, wait); |
| 6580 | t.detach(); |
| 6581 | return false; |
| 6582 | } |
| 6583 | |
| 6584 | // IAT rewrite of every module's kernel32!ExitProcess slot; wrapper runs |
| 6585 | // cooperative Shutdown then chains the original. |