From 42ff9266117a0821a68717a8fc0ce69267524bb3 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 7 Mar 2018 01:13:15 +0300 Subject: [PATCH] Workaround Haiku pthread_join failure in subthreadcreate_test Issue #97 (bdwgc). The underlying pthread_join fails because of some bug in Haiku OS (as of hrev51798) when many threads are created in parallel. * tests/subthread_create.c [__HAIKU__]: Include errno.h. * tests/subthread_create.c [__HAIKU__] (main): If pthread_join returned value is ESRCH then just end the test normally (i.e. ignore the failure of pthread_join); add comment and TODO item. --- tests/subthread_create.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/subthread_create.c b/tests/subthread_create.c index f78a3eb..af74e14 100644 --- a/tests/subthread_create.c +++ b/tests/subthread_create.c @@ -24,6 +24,10 @@ # include #endif +#if defined(__HAIKU__) +# include +#endif + #include #include @@ -128,6 +132,12 @@ int main(void) err = pthread_join(th[i], &res); if (err) { fprintf(stderr, "Failed to join thread: %s\n", strerror(err)); +# if defined(__HAIKU__) + /* The error is just ignored (and the test is ended) to */ + /* workaround some bug in Haiku pthread_join. */ + /* TODO: The thread is not deleted from GC_threads. */ + if (ESRCH == err) break; +# endif exit(1); } # else -- 2.7.4