title: linux semaphore, can a process block itself?
body: <p>I use semget() to get a semaphore, and initialize its VAL to 0, then I want to wait it with semop(), but it directly return. (Another process is designed to get the SEM and release it after some operations)</p>
  
  <p>But if I get a SEM and init its VAL to 0 in a process, and wait it in another process, it works.</p>
  
  <p>Does it mean that a process cannot block itself?</p>
  
  <p>thanks!!!</p>
  
  <p>like this:</p>
  
  <pre><code>int semid = semget(IPC_PRIVATE, 1, IPC_CREAT);
  union semun su;
  su.val = 0;
  semctl(semid, 1, SETVAL, su);
  struct sembuf sb;
  sb.sem_num = 0;
  sb.sem_op  = -1;
  sb.sem_flg = 0;
  semop(semid, &amp;sb, 1);
  </code></pre>