Hello,<div><br></div><div>I have a working code that redirects stdout to a pipe, runs some code and then process the stdout (through the pipe):</div><div><br></div><div><br></div><div><div><span class="Apple-tab-span" style="white-space:pre">                </span>/// Connect STDOUT to pipe</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>// Save old stdout.</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>saved_stdout = dup(STDOUT_FILENO); // save stdout for display later</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>// create pipe</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>if( pipe(out_pipe) != 0 ) { // make a pipe </div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>exit(1);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>// connect stdout to pipe.</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>dup2(out_pipe[1], STDOUT_FILENO); // redirect stdout to the pipe</div>
</div><div><br></div><div>...</div><div>...</div><div>//at some point:</div><div><div><span class="Apple-tab-span" style="white-space:pre">                </span>int read_bytes = read(out_pipe[0], buffer, MAX_LEN); // read from pipe into buffer </div>
</div><div><br></div><div>...</div><div>...</div><div><br></div><div><div><span class="Apple-tab-span" style="white-space:pre">                </span>dup2(saved_stdout, STDOUT_FILENO); // reconnect stdout for testing </div></div><div>
<br></div><div><br></div><div>Now, if I try to run exactly the same code in MPI environment, the "read" function only retrieves part of the message.</div><div>I think this could be because of some MPI redefinition of pipe buffer sizes or similar.</div>
<div><br></div><div>Any ideas?</div><div><br></div><div>Thanks</div><div>Diego </div>