From 14583c5d052fd989e82790782dbfad7a538189d4 Mon Sep 17 00:00:00 2001 From: brainstormi Date: Tue, 22 Dec 2015 00:03:37 +0100 Subject: [PATCH] OSX fix joining main tread with calling thread This is from https://github.com/ninenines/esdl2/pull/11 --- c_src/nif_helpers.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/c_src/nif_helpers.c b/c_src/nif_helpers.c index f1465da..422bce0 100644 --- a/c_src/nif_helpers.c +++ b/c_src/nif_helpers.c @@ -185,10 +185,14 @@ void nif_destroy_main_thread(void* void_st) nif_thread_message* msg = nif_thread_message_alloc(NULL, NULL, NULL); nif_thread_send(st, msg); - enif_thread_join(st->tid, NULL); + #if defined(__APPLE__) && defined(__MACH__) + erl_drv_stolen_main_thread_join(st->tid, NULL); + #else + enif_thread_join(st->tid, NULL); + #endif - enif_cond_destroy(st->cond); enif_mutex_destroy(st->lock); + enif_cond_destroy(st->cond); enif_free(st->mailbox); enif_free(st); }