title: getting the real exit code after proc_open
body: <p>I'm using <code>proc_open</code> in php to <strong>launch a subprocess</strong> and send data back and forth.</p>
  
  <p>At some point I'd like to <strong>wait for the process</strong> to end and retrieve the <strong>exit code</strong>.</p>
  
  <p>The problem is that if the process has <strong>already finished</strong>, my call to <code>proc_close</code> returns -1.  There is apparently much confusion over what <code>proc_close</code> does actually return and I haven't found a way to reliably determine the exit code of a process opened with <code>proc_open</code>.</p>
  
  <p>I've tried using <code>proc_get_status</code>, but it seems to also return -1 when the process has already exited.</p>
  
  <hr>
  
  <h2>Update</h2>
  
  <p>I can't get <code>proc_get_status</code> to <strong>ever give me a valid exit code</strong>, no matter how or when it is called.  Is it broken completely?.</p>