From 2c5f337169b6377cd43e699f557f46846ccdde7b Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Tue, 21 Mar 2017 15:48:31 +0300 Subject: Fix. Correctly handle error from `_beginthreadex` (close #12) `_beginthread` returns -1 in case of error, but `_beginthreadex` returns 0. https://msdn.microsoft.com/en-us/library/kdzttdcb.aspx --- src/llthread.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/llthread.c b/src/llthread.c index eee7290..eb0c861 100644 --- a/src/llthread.c +++ b/src/llthread.c @@ -384,6 +384,9 @@ static int llthread_start(llthread_t *this, int start_detached, int joinable) { #ifndef USE_PTHREAD this->thread = (HANDLE)_beginthreadex(NULL, 0, llthread_child_thread_run, child, 0, NULL); + if(0 == this->thread){ + this->thread = INVALID_THREAD; + } if(INVALID_THREAD == this->thread){ rc = -1; } -- cgit v1.2.3-55-g6feb