title: Continuously write to subprocess using popen in C++
body: <p>I need to open a subprocess using popen, the process will continuously ask for user input... The main process need to send that data over the pipe. </p>
  
  <p>This is my first attempt:</p>
  
  <pre><code>FILE *in;
  char buff[1024];
  
  if(!(in = popen("cd FIX/fix2/src; java -cp .:./* com.fix.bot", "w"))){
      return 1;
  }
  
  while(1){
      char buffer[] = { 'x' };
      fwrite(buffer, sizeof(char), sizeof(buffer), in);
  
      cout &lt;&lt; "Wrote!" &lt;&lt; endl;
      usleep(1000000);
  }
  </code></pre>
  
  <p>However the data is not sent! I need to close the pipe with pclose() so that the data is written to the process. How can I make sure to write the data without having to close the pipe everytime?</p>