diff options
| -rw-r--r-- | sync.c | 14 | 
1 files changed, 14 insertions, 0 deletions
| @@ -12,6 +12,8 @@ int  pthread_join(pthread_t thread, void ** valueptr)  {    LPDWORD exitcode; +  _pthread_threads_thread_t * target; +    pthread_t us = pthread_self();    /* First check if we are trying to join to ourselves. */ @@ -20,6 +22,18 @@ pthread_join(pthread_t thread, void ** valueptr)        return EDEADLK;      } +  /* If the thread is detached, then join will return immediately. */ + +  target = _pthread_find_thread_entry(thread); +  if (target < 0) +    { +      return EINVAL; +    } +  else if (target->detached == PTHREAD_CREATE_DETACHED) +    { +      return ESRCH; +    } +    /* Wait on the kernel thread object. */    switch (WaitForSingleObject(thread, INFINITE))      { | 
