title: Communicate with a subprocess using pipes on other than stdout/stderr
body: <p>This is how I fork/exec a subprocess and communicated with it (pseudocode):</p>
  
  <pre><code>int cout_pipe[2];
  pipe(cout_pipe);
  fork();
  if (child)
  {
    dup2(cout_pipe[1],STDOUT_FILENO);
    execv();
  }
  if (parent)
  {
    File* cout_file = fdopen(cout_pipe[0], "r");
  }
  </code></pre>
  
  <p>My question is:</p>
  
  <p>I don't really want to read the stdout of my subprocess, I would like the subprocess to write on a file descriptor other than stdout. And, I'd like the above code to read from that file descriptor.</p>
  
  <p>The subprocess is written in python, the main process in C++.</p>
  
  <p>I am thinking I can change that line, from:</p>
  
  <pre><code>dup2(cout_pipe[1],STDOUT_FILENO);
  </code></pre>
  
  <p>To</p>
  
  <pre><code>dup2(cout_pipe[1],MY_OWN_RANDOM_FD_NUMBER);
  </code></pre>
  
  <p>And code the subprocess in a way that I write to MY_OWN_RANDOM_FD_NUMBER instead of stdout.</p>
  
  <p>Is this a good solution? doable? How can I figure out a good MY_OWN_RANDOM_FD_NUMBER? Is there better alternatives?</p>