title: error creating more than one semaphore
body: <p>so there's this assignment the teacher gave us, and she already gave us some a procedure to create semaphore along with some other procedures. I could create one a semaphore with that procedure but couldn't do more than one, the it shows an error when trying to create the second one. I really tried to look for a solution for this but I couldn't even find a code with a similar procedure. is there something I should change within the procedure "sem_create" ? </p>
  
  <p>here's the code: </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/wait.h&gt;
  #include &lt;sys/ipc.h&gt;
  #include &lt;sys/sem.h&gt;
  
  int sem_create(key_t CLEF,int initval) {
      union semun {
          int val;
          struct semid_ds *buf;
          ushort *array;
      } arg_ctl;
      int semid;
      semid = semget(ftok("Disjktra.h&lt;votre login&gt;",CLEF),
                     1, IPC_CREAT|IPC_EXCL|0666);
      if (semid == -1)
          return -1;
      arg_ctl.val = initval; // sth is missing here
      if (semctl(semid, 0, SETVAL, arg_ctl) == -1)
          return -1;
      return semid;
  }
  
  
  /////////////////////////////////
  /////////////////////////////////
  
  void main() {
      int i, CLE=33, S1=0, S2=0;
  
      if ((S1 = sem_create(CLE,0)) == -1) {
          perror("error in creating semaphore 1");
          exit(-1);
      }
  
      if ((S2 = sem_create(CLE,0)) == -1) {
          perror("error in creating semaphore 2");
          exit(-1);
      }
  }
  </code></pre>
  
  <p>Output: </p>
  
  <pre><code>error in creating semaphore 2 :File exists
  </code></pre>