sleep thread after panicking
This commit is contained in:
parent
228bef5a68
commit
3f1d714e7b
@ -109,8 +109,9 @@ void _log_panic(struct string msg)
|
||||
if (!atomic_i32_eval(&G.initialized)) { return; }
|
||||
|
||||
if (G.file_valid) {
|
||||
sys_file_write(G.file, BUFFER_FROM_STRING(STR("** PANICKING **\n")));
|
||||
sys_file_write(G.file, BUFFER_FROM_STRING(STR("******** PANICKING ********\n")));
|
||||
sys_file_write(G.file, BUFFER_FROM_STRING(msg));
|
||||
sys_file_write(G.file, BUFFER_FROM_STRING(STR("\n***************************\n")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -101,6 +101,7 @@ GLOBAL struct {
|
||||
LARGE_INTEGER timer_start;
|
||||
i32 scheduler_period_ms;
|
||||
DWORD thread_tls_index;
|
||||
u32 main_thread_id;
|
||||
|
||||
/* Panic */
|
||||
struct atomic_i32 panicking;
|
||||
@ -1859,6 +1860,11 @@ void sys_panic(struct string msg)
|
||||
|
||||
WRITE_BARRIER();
|
||||
SetEvent(G.panic_event);
|
||||
|
||||
/* Wait for thread to be terminated */
|
||||
if (GetCurrentThreadId() != G.main_thread_id) {
|
||||
Sleep(INFINITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1995,6 +2001,7 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
|
||||
* Win32 setup
|
||||
* ========================== */
|
||||
|
||||
G.main_thread_id = GetCurrentThreadId();
|
||||
SetThreadDescription(GetCurrentThread(), L"Main thread");
|
||||
|
||||
/* Set up panic event */
|
||||
@ -2085,8 +2092,10 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
|
||||
|
||||
/* Call app thread and wait for return */
|
||||
{
|
||||
/* Start app thread */
|
||||
struct sys_thread app_thread = sys_thread_alloc(&app_thread_entry_point, NULL, STR("[P9] App thread"));
|
||||
|
||||
/* Get app thread handle */
|
||||
HANDLE app_thread_handle = 0;
|
||||
sys_rw_mutex_lock_shared(&G.threads_rw_mutex);
|
||||
{
|
||||
@ -2095,7 +2104,7 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
|
||||
}
|
||||
sys_rw_mutex_unlock_shared(&G.threads_rw_mutex);
|
||||
|
||||
/* Wait for thread exit or panic */
|
||||
/* Wait for either app thread exit or panic */
|
||||
if (app_thread_handle) {
|
||||
HANDLE wait_handles[] = {
|
||||
app_thread_handle,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user