From 57d8dd92ef5261d4fc17c6b4b0d756839407524b Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 1 Dec 2013 09:32:24 +0100 Subject: [PATCH] pthread_join: Retry when interrupted as mandated by POSIX. The spec explicitly states that pthread_join shall not return EINTR, so we have to retry the wait when it gets interrupted instead of letting the error code through. --- src/system/libroot/posix/pthread/pthread.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/system/libroot/posix/pthread/pthread.cpp b/src/system/libroot/posix/pthread/pthread.cpp index 1e7c4e9f96..6c441e1f21 100644 --- a/src/system/libroot/posix/pthread/pthread.cpp +++ b/src/system/libroot/posix/pthread/pthread.cpp @@ -189,7 +189,11 @@ int pthread_join(pthread_t thread, void** _value) { status_t dummy; - status_t error = wait_for_thread(thread->id, &dummy); + status_t error; + do { + error = wait_for_thread(thread->id, &dummy); + } while (error == B_INTERRUPTED); + if (error == B_BAD_THREAD_ID) RETURN_AND_TEST_CANCEL(ESRCH);