title: Semop returns identifier removed
body: <p>I am creating a multi-process application with a shared memory segment and a semaphore locking it and signal handlers. </p>
  
  <p>Whenever I lock and unlock my semaphore everything is ok, as long as it is in my main program (or one of the children). </p>
  
  <p>The problem occurs when I am inside a signal handler. There I lock the semaphore, do some updates on the shared memory segment and unlock it.</p>
  
  <p>I have a <code>struct sembuf</code> let's call it <code>sb</code>.</p>
  
  <p>My lock code</p>
  
  <pre><code>void semLock(){
  sb.sem_op=-1;
  semop(sID,sb,sizeof(sb);
  }
  </code></pre>
  
  <p>my unlock code</p>
  
  <pre><code>void semUnlock(){
  sb.sem_op=1;
  semop(sID,sb,sizeof(sb);
  }
  </code></pre>
  
  <p>and how I do my stuff</p>
  
  <pre><code>void signalHandler(int segnum){
  semLock();
  //do some stuff
  semUnlock();
  }
  </code></pre>
  
  <p>There is no real reason why this would not work as <code>sID</code> is global and is inherited to all the children the parent process creates and also when the children are running other code that locks and unlocks the semaphore.</p>
  
  <p>I think the issue is that this is inside a signal handler but I do not understand why.
  The error that is printed in the terminal is</p>
  
  <pre><code>semop failed identifier removed
  </code></pre>
  
  <p>I try googling the error but did not find any meaningful or relevant information on what might cause it.</p>
  
  <p><strong>EDIT</strong>
  when I create <code>sb</code> it's initialized with <code>{0,-1,0}</code> 
  I only have one semaphore in my ipcs</p>