Ticket #8836: 0002-calling-pthread_join-on-a-detached-thread-should-ret.patch

File 0002-calling-pthread_join-on-a-detached-thread-should-ret.patch, 863 bytes (added by 0x0dev, 12 years ago)
  • src/system/libroot/posix/pthread/pthread.cpp

    From 58dd7bbd1627ed4a3536e34c49fdda9c3a7ea0ab Mon Sep 17 00:00:00 2001
    From: Jason Whitehorn <jason.whitehorn@gmail.com>
    Date: Sat, 4 Aug 2012 20:11:24 -0500
    Subject: [PATCH 2/2] calling pthread_join on a detached thread should return
     EINVAL
    
    ---
     src/system/libroot/posix/pthread/pthread.cpp |    3 +++
     1 file changed, 3 insertions(+)
    
    diff --git a/src/system/libroot/posix/pthread/pthread.cpp b/src/system/libroot/posix/pthread/pthread.cpp
    index 4c5104a..71e5eca 100644
    a b pthread_join(pthread_t thread, void** _value)  
    191191
    192192    if (_value != NULL)
    193193        *_value = thread->exit_value;
     194   
     195    if(thread->flags & THREAD_DETACHED)
     196        return EINVAL;;
    194197
    195198    if ((atomic_or(&thread->flags, THREAD_DETACHED) & THREAD_DEAD) != 0)
    196199        free(thread);