title: C++ fork() and execv() problems
body: <p>I am kind of newbie on C++, and working on a simple program on Linux which is supposed to invoke another program in the same directory and get the output of the invoked program without showing output of the invoked program on console. This is the code snippet that I am working on:</p>
  
  <pre><code>    pid_t pid;
      cout&lt;&lt;"General sentance:"&lt;&lt;endl&lt;&lt;sentence&lt;&lt;endl;
      cout&lt;&lt;"==============================="&lt;&lt;endl;
      //int i=system("./Satzoo");
      if(pid=fork()&lt;0)
          cout&lt;&lt;"Process could not be created..."&lt;&lt;endl;
      else
      {
          cout&lt;&lt;pid&lt;&lt;endl;
          execv("./Satzoo",NULL);
      }
      cout&lt;&lt;"General sentance:"&lt;&lt;endl&lt;&lt;sentence&lt;&lt;endl;
      cout&lt;&lt;"==============================="&lt;&lt;endl;
  </code></pre>
  
  <p>One of the problem I encounter is that I am able to print the first two lines on console but I cant print the last two lines. I think the program stops working when I invoke the Satzoo program.
  Another thing is that this code invokes Satzoo program twice, I dont know why? I can see the output on screen twice. On the other hand if I use system() instead of execv(), then the Satzoo works only once.</p>
  
  <p>I haven't figured out how to read the output of Satzoo in my program.</p>
  
  <p>Any help is appreciated.</p>
  
  <p>Thanks</p>