title: How do I use proc_open() with a non-standard file descriptor on Linux?
body: <p>The <a href="http://php.net/manual/en/function.proc-open.php" rel="nofollow"><code>proc_open()</code></a> documentation states that it's possible to use other file descriptors than the standard ones:</p>
  
  <blockquote>
    <p>The file descriptor numbers are not limited to 0, 1 and 2 - you may
    specify any valid file descriptor number and it will be passed to the
    child process.</p>
  </blockquote>
  
  <p>But how do you actually go about doing this?</p>
  
  <p>What do you need to do on the parent and child process to for example use an extra input and output pipe with a proc_open call?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>A related question - If the launched process was also a PHP function, you can access an arbitrary fd in PHP with the stream wrapper <a href="http://php.net/manual/en/wrappers.php.php" rel="nofollow"><code>php://fd/3</code></a> (replace 3 with the fd number), but this feature is only available in PHP 5.3.6+.  Is there any way of accessing an arbitrary fd in PHP 5.2?</p>