title: Semaphore error in Linux - :Invalid argument error no :22 (EINVAL)
body: <p>I am trying to execute a C program in linux and I am getting error as "P_Semaphore :Invalid argument error no :22," can someone help</p>
  
  <pre><code>Int P_Semaphore(int i_sem_id)
  {
   int i_code_returns;
   struct sembuf t_semop;
   #ifdef TRACE
   Debug(N_DEBUG_8, "P_Semaphore", "Entree, i_sem_id=%d&lt;&lt;&lt;&lt;&lt;&lt;\n", i_sem_id);
   #endif
   t_semop.sem_num = 0;
   t_semop.sem_op  = -1;
   t_semop.sem_flg = 0;
   do
   {
     i_code_retour = semop(i_sem_id, &amp;t_semop, 0);
  
   } while ((i_code_returns == KO) &amp;&amp; (errno == EINTR));
  
   if (i_code_retour == KO)
   {
     printf( "%s(%d):Error semaphore making attempt %d,errno = %d\n", M_HEADER, i_sem_id, errno);
    perror("P_Semaphore");
   }
  </code></pre>