title: Pthread: lock PTHREAD_MUTEX_ERRORCHECK mutex from non-owner thread
body: <p>classical question please; 
  I didn't find confirmation from code; 
  C language.
  I'm running the below code on Windows.</p>
  
  <pre><code>/* This is an implementation of the threads API of POSIX 1003.1-2001.*/
  #include &lt;pthread.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  pthread_mutex_t mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
  //equivalent to PTHREAD_MUTEX_ERRORCHECK
  
  void* thread_function(void *args)
  {
      int rc;
      rc = pthread_mutex_unlock( &amp; mutex );
      printf( "[thread_function] pthread_mutex_unlock rc: %d \n", rc);
      return 0;
  }
  
  int main(int argc, char* argv[])
  {
      int rc;
      pthread_t id;
  
      pthread_mutex_lock( &amp;mutex );
      rc =  pthread_create(&amp;id, NULL, thread_function, NULL);
      pthread_join(id, NULL);
  
      printf( "[main] completed\n");
  }
  </code></pre>
  
  <p><code>rc = pthread_mutex_unlock( &amp; mutex );</code> - returns rc equal to 1 which is as  expected.</p>
  
  <p>but when I change the code to <code>rc = pthread_mutex_lock( &amp; mutex );</code> - the error does not occur.
  But in many Pthread API doc it is mentioned that:
  "<em>If the mutex type is PTHREAD_MUTEX_ERRORCHECK, then error checking shall be provided. If a thread attempts to relock a mutex that it has already locked, <strong>an error shall be returned</strong>.</em>"</p>
  
  <p>But it is not returned for me, and the question why?
  The only guess I have - it depends on PThread realization which I'm using.
  And it also may depend on OS; i.e. same code and the same version of Pthread lib will give different result on Linux.</p>
  
  <p>Can anyone please clarify?</p>
  
  <p>Thanks!</p>