title: Popen giving some strange character in output when running multiple command in it
body: <p>I write code to fetch the fragmented packet by using a unique Identification field from pcap file. So I run scripting command in my C++ program. </p>
  
  <p>First tshark command will fetch all the identification field from the packet with the callID mentioned in the filter and the second one will fetch all the fragmented packet identification field in that pcap.
  And awk command compare then and find the unique identification field present in both the tshark command output. </p>
  
  <p>Command will be like---</p>
  
  <blockquote>
    <p>cmd = (awk 'FNR==NR{a[$0]=1;next}($0 in a)' &lt;((/usr/sbin/tshark -r
    /data/traces/TRACES.pcap 'sip.Call-ID=="1-4740@10.133.0.1" or
    sip.Call-ID=="57b116c-5b20924e-93dcd"' -T fields -e ip.id)
    2>/dev/null) &lt;((/usr/sbin/tshark -r /data/traces/TRACES.pcap
    'ip.flags.mf==1' -T fields -e ip.id) 2>/dev/null)) 2>/dev/null</p>
  </blockquote>
  
  <p>Reading data by </p>
  
  <pre><code>    FILE * stream = popen(cmd.c_str(), "r");
      if (!stream)
      {
          LOG_DEBUG("popen failed");
      }
  
      fflush(stream);
  </code></pre>
  
  <blockquote>
    <p>NOTE:: I tried with fflush and without fflush still giving me strange
    character. </p>
  </blockquote>
  
  <pre><code>while(fgets(buffer, 40, stream) != NULL)
  {    
     data = buffer;
     result += data + '\n';
  }
  
  if(data.empty()) {
     data = buffer;
     result = data + '\0';
  }
  </code></pre>
  
  <p>NOTE:: Tried with the system() command also but this also returns me a strange Character</p>
  
  <p>OUTPUT will be like -->  <strong>0^_iÏO^?</strong> </p>
  
  <p>I notice a strange thing that when I execute tshark command individually and save the output in a different file and then using awk command on that files then it will give the correct output. 
  And Command is correctly running in the terminal also.</p>