title: Wait until 2 pid write to FIFO(named pipe)
body: <p>Im trying to make a Tic Tac Toe game with server-client using FIFO(named pipe) and shared memory.</p>
  
  <p>The first step is to write the pid of the client process to the FIFO.
  And in the server process i need to wait until 2 pids was passed in the FIFO (from 2 different client process).</p>
  
  <p>Right now im just doing 2 read from the pipe but it's not works proper. Do i need to read in a while loop or something?</p>
  
  <p>The client code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;sys/stat.h&gt; 
  #include &lt;fcntl.h&gt;
  #include &lt;unistd.h&gt;
  
  void main()
  {
      int fd;
      int pid=getpid();
      pid_t pid1=getpid();
      fd=open("fifo_clientTOserver",O_WRONLY);
  
      write(fd,&amp;pid1,sizeof(pid_t));
      printf("%d\n",pid1);
      while(1);
  
  }
  </code></pre>
  
  <p>The server code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;sys/stat.h&gt; 
  #include &lt;fcntl.h&gt;
  #include &lt;unistd.h&gt;
  
  void main()
  {
      int fd;
      pid_t pid;
      ftok("shmdemo.c","j");
      mkfifo("fifo_clientTOserver",400);
      fd=open("fifo_clientTOserver",O_RDONLY);
      read(fd,&amp;pid,sizeof(pid_t));
      printf("%d",pid);
      read(fd,&amp;pid,sizeof(pid_t));
      printf("%d",pid);
  
  
  //sleep(2);
  }
  </code></pre>
  
  <p>I want that the server will wait until 2 clients are running, how should i do that?</p>
  
  <p>Thank you very much,
  Asaf.</p>