title: Subprocess communication. C++
body: <p>I'm trying to write a C++ program which will start new process (some script, programm, command) like daemon and gets some info from it (stdout). I'm trying to use popen(). But subprocess finishing when main program complete. I dont know, does C++ have something easy in use like Python (subprocessing). There is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  int main(int argc, char *argv[]) {
    FILE *in;
    char buff[512];
    in = popen(argv[1], "r");
    fgets(buff, sizeof(buff), in);
    cout &lt;&lt; buff;
  }
  </code></pre>
  
  <p>P.S: &amp; in the end of executive command doesn't helps.</p>