title: semget not such file or directory
body: <p>I'm trying to get this code working but I can't. I manage to create some code that doesn't show any compilation error or warning, but when I try to execute it fails with this error:</p>
  
  <p>semget: No such file or directory</p>
  
  <p>This is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;sys/wait.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/ipc.h&gt;
  #include &lt;sys/shm.h&gt;
  #include &lt;sys/sem.h&gt;
  #include &lt;time.h&gt;
  
  int main(int argc, char *argv[]) {
     key_t llave1,llavesem;   
     int idmem,idsem; 
     struct sembuf op;    
     llavesem=ftok("/tmp",'b');
  
     idsem=semget(llavesem,1,0); /* This is the line giving the error*/
     if (idsem==-1) {
        perror ("semget");
        return 1;
     }
  
     semctl(idsem,1,SETVAL, &amp;valini);
     op.sem_num=0;
     op.sem_flg=0;
  
     /*Some code here*/
  
     op.sem_op=-1;
     semop(idsem,&amp;op,1);
  
     /*Some code here*/
  
     op.sem_op=1;
     semop(idsem,&amp;op,1);
     semctl(idsem,1,IPC_RMID);
  }
  </code></pre>
  
  <p>If I include the header file sys/sem.h ... why the executable file doesn't find it?</p>
  
  <p>What I'm doing wrong?</p>
  
  <p>Thanks in advance and best regards,</p>
  
  <p><em><strong></em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>**<em></strong> EDIT <strong></em>**<em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>****</strong> </p>
  
  <p>Following the answers given, I create the files, to do that I add this include:</p>
  
  <pre><code>   #include &lt;fcntl.h&gt;
  </code></pre>
  
  <p>And I add this two lines before the ftok sentence:</p>
  
  <pre><code>llave1=open("/tmp/a",O_RDWR|O_CREAT,0644);
  llavesem=open("/tmp/b",O_RDWR|O_CREAT,0644);
  </code></pre>
  
  <p>The files are created but I still having the same error.</p>
  
  <pre><code>ubuntu@/: ls -l /tmp/a
   -rw-r--r-- 1 ubuntu ubuntu 0 Sep 11 00:11 /tmp/a 
  ubuntu@/: ls -l /tmp/b
   -rw-r--r-- 1 ubuntu ubuntu 0 Sep 11 00:11 /tmp/b 
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Thanks!!</p>