title: How to send continuous stream of data from one process to another via EXECL
body: <p>I am writing C program which constantly generates two string values named <code>stateName</code> and <code>timer</code> (with the rate of five times per second). I need to concatenate and pass them to another process called <code>ProcessNo3_TEST</code> which is responsible for tokenizing and also displaying them.</p>
  
  <p>The problem is I don't know how to pass them <strong>continuously</strong> via <code>execl</code>. I had a couple of attempts but none of them were successful. Here is my code which works fine for a single pair of values (e.g. <code>UP2</code> and <code>98</code>):</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #define READ 0
  #define WRITE 1
  
  int FIFO[2];
  char fileDescriptor[10];
  
  char* stringMaker( char *s1,char *s2 );
  
  int main()
  {
      char lengthInChar[15],msg[200];
      int msgLength,i;
      char *stateName, *timer;
      if (pipe(FIFO) == -1)
      {
          printf("cannot create pipe\n");
          exit(1);
      }
      sprintf(fileDescriptor, "%d", FIFO[READ]);
  
      stateName = "UP2";              // for instance
      timer = "98";                   // for instance
  
      msgLength = strlen(stateName) + strlen(timer) +3;
      strcpy(msg, stringMaker(stateName, timer) );
      write(FIFO[WRITE], msg, msgLength);
  
      switch (fork())
      {
      case 0:
          sprintf(lengthInChar, "%d", msgLength);
          execl("ProcessNo3_TEST", "ProcessNo3_TEST", lengthInChar, fileDescriptor, NULL);
          exit(1);
      case -1:
          perror("fork() failed--&gt;");
          exit(2);
      default:
          break;
      }
      sleep(10);
      exit(0);
  }
  
  char* stringMaker( char *s1,char *s2 )
  {
      char *s3;
      strcpy(s3,s1);
      strcat(s3,"-");
      strcat(s3,s2);
      strcat(s3,"-");
      strcat(s3,"\0");
      return s3;
  }
  </code></pre>
  
  <p>Can anyone help on this please?</p>
  
  <p>(I am running CygWin on Windows by the way)</p>
  
  <p><strong>----------UPDATE-------------</strong></p>
  
  <p>As advised in comments below, I found a good example of <code>fdopen()</code> which solved my problem. (<a href="http://www.gnu.org/software/libc/manual/html_node/Creating-a-Pipe.html" rel="nofollow">Link</a>)</p>