title: Script bash write in a fifo and c program read from it
body: <p>I have a bash script that writes to a fifo. And I have a C program that reads from the same fifo.</p>
  
  <p>I am sure the script works because I've tried to read from the fifo with another script and everything worked. But something does not work in C program. When I run my script and when I run the C program it's like they await each other. Here's the code.</p>
  
  <p>The script is (the writer):</p>
  
  <pre><code>#!/bin/bash
  
  fifo_name="myfifo";
  
  # Se non esiste, crea la fifo;
  [ -p $fifo_name ] || mkfifo $fifo_name;
  
  echo "3" &gt; $fifo_name;
  echo "6" &gt; $fifo_name;
  </code></pre>
  
  <p>And here the c program (the reader) :</p>
  
  <pre><code>#include &lt;fcntl.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;fcntl.h&gt;
  
  #define MAX_BUF 1024
  
  int main(int argc, char *argv[])
  {
      int fd, i;
      char * myfifo = argv[1];
      char buf[MAX_BUF];
  
      fd = open(myfifo, O_RDONLY);
  
      while (1) {
          if(read(fd, buf, MAX_BUF) &gt; 0)
          {
              printf("Received: %s\n", buf);      
          }
      }
  
      close(fd);
  
      return 0;
  }
  </code></pre>
  
  <p>Where am I going wrong? </p>
  
  <p>Thank you.</p>