title: C using select() to read from two named pipes (FIFO)
body: <p>I am currently trying to write a program in C which will read from two named pipes and print any data to stdout as it becomes available.</p>
  
  <p>for example:  If I open two terminals and <code>./execute pipe1 pipe2</code> in one of the terminals (with pipe1 and pipe2 being valid named pipes) and then type <code>echo "Data here." &gt; pipe1</code> then the name of the pipe (here it is <code>pipe1</code>), the size, and the data should print to stdout-- Here it would look like <code>pipe1 [25]: Data here.</code></p>
  
  <p>I know I need to open the pipes with the <code>O_RDONLY</code> and <code>O_NONBLOCK</code> flags. I have looked at many examples (quite a few on this forum) of people using <code>select()</code> and I still don't understand what the different parameters being passed to <code>select()</code> are doing. If anyone can provide guidance here it would be hugely helpful. Below is the code I have so far.</p>
  
  <pre><code> int pipeRouter(char[] fifo1, char[] fifo2){
      fileDescriptor1 = open(fifo1, O_RDONLY, O_NONBLOCK);
      fileDescriptor2 = open(fifo2, O_RDONLY, O_NONBLOCK);
  
      if(fileDescriptor1 &lt; 0){
          printf("%s does not exist", fifo1);
      }
      if(fileDescriptor2 &lt; 0){
          printf("%s does not exist", fifo2);
      }
  }
  </code></pre>