title: C- Semaphore sem_getvalue not returning what I'm expecting?
body: <p>I've been trying to get myself more acquainted with semaphores and was wondering why this code isn't printing the value I expect.</p>
  
  <pre><code>#include &lt;semaphore.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(int argc, char * argv[]) {
      sem_t sem;
      sem_init(&amp;sem, 0, 1);
      int value;
      sem_getvalue(&amp;sem, &amp;value);
      printf("%d\n",value);
  
      return 0;
  }
  </code></pre>
  
  <p>It prints 0 for the value.  But from my understanding it should be getting the value I initialized the semaphore with which is 1?  I tried using a semaphore in some code with pthreads and I initialized the semaphore with a value of 1, but when I called the sem_getvalue function it was printing 32767.  Am I missing something here?  Thanks in advance.</p>
  
  <p>Edit: sem_init and sem_getvalue both return -1</p>
  
  <p>Edit:  Solved. It appears unnamed semaphores aren't implemented on Mac.</p>