Why pipe get messy code when use valgrind --xml-fd
<p>here is my code:</p>

<pre><code>int fd[2];
pipe(fd);
fd[0];
fd[1];
std::string cmd = "valgrind --leak-check=yes --track-origins=yes --xml=yes --xml-fd=";
cmd += std::to_string(fd[1]);
cmd += " /tmp/home/roroco/Dropbox/rbs/ro_cmds_global/c/valgrind/ex/ex2";
system(cmd.c_str());
close(fd[1]);
int n = 1024;
char buffer[1024];
std::string r;
while (read(fd[0], buffer, n) != 0) {
    r += buffer;
}
std::cout &lt;&lt; r &lt;&lt; std::endl;
</code></pre>

<p>the executable "ex2" code is:</p>

<pre><code>    int *is;
    is[2] = 2;
    return (0);
</code></pre>

<p>here is <a href="https://gist.github.com/782aad94fe4240088e6b" rel="nofollow">output</a>, I get messy code like <code>&lt;\360\034@</code></p>

<p><strong>update</strong> </p>

<p>when i use --xml-file, it output normal text like <a href="https://gist.github.com/da213aea0f0816846eda" rel="nofollow">this</a></p>