title: Call proc_open without wait for response
body: <p>As I have to explain why my question different then the question <a href="https://stackoverflow.com/questions/14810152/php-background-process-in-windows-environment">php background process in windows environment</a>, the explanation is:</p>
  
  <p>First of all, I want to run a shell script via proc_open in php, not via exec.</p>
  
  <blockquote>
    <p>Also conceptually its a isolated thread in my mind(if it succeded),
    which will run in backend, populating a log file or a queued db table
    from which I can poll my result.</p>
  </blockquote>
  
  <hr>
  
  <p>I have a proc_open code, which eventually runs a php file in cli:</p>
  
  <p>File: proc-open.php</p>
  
  <pre><code>    $descriptorspec = array(
         0 =&gt; array("pipe", "r"),
         1 =&gt; array("pipe", "w"),
         2 =&gt; array("file", "midirectory_path/error-output.txt", "a")
      );
      $process = proc_open("php -f myphpfile.php", $descriptorspec, $pipes, "midirectory_path");
      if (!is_resource($process)) {
          die ('Could not execute RUNMYSCRIPT');
      }
  
      sleep(10);
      fwrite($pipes[0], 'q');
      $result = fread($pipes[1], 1);
      echo stream_get_contents($pipes[1]);
      proc_close($process);
  </code></pre>
  
  <p>And I want to hit this line of code but do not want to wait for the response:
  File: proc-call.php</p>
  
  <pre><code>$url = 'http://example.com/proc-open.php';
  $parts=parse_url($url);
  $fp = fsockopen($parts['host'],isset($parts['port'])?$parts['port']:80, $errno, $errstr, 30);
  $out = "GET ".$parts['path']." HTTP/1.1\r\n";
  $out.= "Host: ".$parts['host']."\r\n";
  $out.= "Content-Length: 0"."\r\n";
  $out.= "Connection: Close\r\n\r\n";
  fwrite($fp, $out);
  fclose($fp);
  </code></pre>
  
  <p>But it is not calling the proc_open and I can't see any php cli in my task manager.
  I hit in browser as <a href="http://example.com/proc-call.php" rel="nofollow noreferrer">http://example.com/proc-call.php</a>, it return 200.</p>
  
  <p>Need help.</p>