title: How to write messages into a FIFO and read it from another process simultaneously
body: <p>In Unix system, I just knew that we could use FIFO file for communication between two processes and I've tested it with C projects.</p>
  
  <p>Now I'm wondering if we can do something like this:</p>
  
  <ul>
  <li>Open two terminals.</li>
  <li>Use one to write messages into a FIFO and use the
  other to read it.</li>
  <li>When I put something into the FIFO at the first terminal, the second terminal will show it immediately.</li>
  </ul>
  
  <p>I've tried the following, but it doesn't work. On one terminal:</p>
  
  <pre><code>mkfifo fifo.file
  echo "hello world" &gt; fifo.file
  </code></pre>
  
  <p>On the other terminal:<br></p>
  
  <pre><code>cat fifo.file
  </code></pre>
  
  <p>Now I can see the <code>"hello world"</code>. However, both processes finish immediately and I can't continue typing / reading the <code>fifo.file</code>anymore.</p>