From 1974d27debaecf6c72514e9cfd4908fbe576bb32 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Fri, 6 Mar 2020 11:09:08 +0800 Subject: [PATCH] make sure the event parsor thread is joinable --- src/kernel/init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/kernel/init.c b/src/kernel/init.c index 22f5c3a4..9fd8a6fd 100644 --- a/src/kernel/init.c +++ b/src/kernel/init.c @@ -334,7 +334,9 @@ static BOOL SystemThreads(void) // then post the message to the approriate message queue. // this thread should also have a higher priority. pthread_create (&_th_parsor, NULL, EventLoop, &wait); - pthread_detach (_th_parsor); + // XXX: Since 5.0.0, event parsor should be joinable + //pthread_detach (_th_parsor); + sem_wait (&wait); sem_destroy (&wait); @@ -626,6 +628,7 @@ void GUIAPI TerminateGUI (int not_used) /* Tell event parsor quit */ _is_minigui_running = 0; + pthread_cancel (_th_parsor); pthread_join (_th_parsor, NULL); __mg_license_destroy(); @@ -688,6 +691,7 @@ void GUIAPI ExitGUISafely (int exitcode) /* Tell event parsor quit */ _is_minigui_running = 0; + pthread_cancel (_th_parsor); pthread_join (_th_parsor, NULL); }