title: cURL causing page to hang
body: <p>I'm using the current code to attempt to use cURL to asynchronously execute two scripts.  Each script is hosted on a different domain and take ~30 seconds to complete.  I'm wanting these to run in the background so that the page continues to load, but it's hanging until they complete.  Am I completely wrong in my thinking of how cURL works?  Or did I just do something wrong?</p>
  
  <p>UPDATE:</p>
  
  <pre><code>$.ajax({
      type    : 'POST',
      url     : 'ajax.php?mode=process',
      data    : '$url',
      complete: function(data)
      {
          $('#test'+num).append('Operation successful.');
      }
  });
  </code></pre>
  
  <p>Num is the ID of the div.  They're generated through code.  All this works properly, except that cURL locks the server until it's finished processing the files.</p>
  
  <p>The code below is now on another page specifically for processing the URLs passed in from the jQuery ajax call above.</p>
  
  <pre><code>$cURLs = array(
      "script_url?param1=1&amp;param2=2",
      "script_url?param1=5&amp;param2=6");
  $result = array();
  $mh = curl_multi_init();
  
  foreach ($data as $id =&gt; $d) 
  {
      $cURLs[$id] = curl_init();
      $url = (is_array($d) &amp;&amp; !empty($d['url'])) ? $d['url'] : $d;
      curl_setopt($cURLs[$id], CURLOPT_URL,            $url);
      curl_setopt($cURLs[$id], CURLOPT_HEADER,         0);
      curl_setopt($cURLs[$id], CURLOPT_RETURNTRANSFER, 1);
  
      if (is_array($d)) 
      {
              if (!empty($d['post'])) 
              {
                      curl_setopt($cURLs[$id], CURLOPT_POST,       1);
                      curl_setopt($cURLs[$id], CURLOPT_POSTFIELDS, $d['post']);
              }
      }
  
      if (!empty($options))
              curl_setopt_array($cURLs[$id], $options);
  
      curl_multi_add_handle($mh, $cURLs[$id]);
  }
  
  $running = null;
  do 
  {
      curl_multi_exec($mh, $running);
  } while($running &gt; 0);
  
  foreach($cURLs as $id =&gt; $c) 
  {
      $result[$id] = curl_multi_getcontent($c);
      curl_multi_remove_handle($mh, $c);
  }
  
  curl_multi_close($mh);
  echo "&lt;pre&gt;" . print_r($result, 1) . "&lt;/pre&gt;";
  </code></pre>