title: PHP script runs fine in firefox but appears to infinite loop in other browsers
body: <p>I have a PHP script on my site that is called using the jquery ajax function. Basically the user presses a button on my site and it sends an ajax call to this PHP script, which then uses proc_open to call a python script on my server. This all works fine when I test it in firefox, but when I test it in other browsers (chrome, safari, mobile safari) the script infinite loops. I have also tried calling the PHP script directly (by pasting the url into the browser) to check if its an infinite loop in my jquery and I get the same result (runs fine in ff, but infinite loops in all other browsers). From what I understand PHP code is executed server side and then the output is sent to the client browser so I cannot figure out why the script is only running in firefox. Ive also tried SSHing into my server and running the python script from command line and it runs fine, so I dont think its a problem with the python script. </p>
  
  <p>Heres my php code:</p>
  
  <pre><code>&lt;?php
  require('../include/constants.php');
  session_start();
  if(!isset($_SESSION['logged_in'])||!$_SESSION['logged_in'])
  {
      header('location:../login.php');
  }
  $link = mysql_connect(DB_SERVER,DB_USER,DB_PASSWORD);
  mysql_select_db(DB_NAME);
  $q = "SELECT `cupiduser`,`cupidpass` FROM `users` WHERE `email`='".$_SESSION['email']."' LIMIT 1;";
  $result = mysql_query($q);
  $row = mysql_fetch_assoc($result);
  $minage = $_GET['min'];
  $maxage = $_GET['max'];
  $descriptorspec = array(
     0 =&gt; array("pipe", "r"),  // stdin is a pipe that the child will read from
     1 =&gt; array("pipe", "w"),  // stdout is a pipe that the child will write to
     2 =&gt; array("pipe", "w") // stderr is a file to write to
  );
  $cmd = 'python ~/data/users/demo2.py "'.$row['cupiduser'].'" "'.$row['cupidpass'].'" "'.$minage.'" "'.$maxage.'"';
  $proc = proc_open($cmd, $descriptorspec, $pipes);
  if(is_resource($proc))
  {
      fclose($pipes[0]);
      $count = fread($pipes[1], 512);
      fclose($pipes[1]);
      fclose($pipes[2]);
      $exit = proc_close($proc);
  }
  echo trim($count);
  ob_end_flush();
  ob_flush();
  flush();
  ob_start();
  ?&gt;
  </code></pre>
  
  <p>The python code is just running a few calculations and then at the end it returns a number like this:</p>
  
  <pre><code>print str(count)
  </code></pre>