Hi sfullman,
Thanks for the reply.. I have finally figured out a way to prevent this behavior from happening.
First let me explain all the things I tried, just incase someone else happens to be suffering from the same issue.
The following is the scenario which causes popen to hang the session:
I have an upload page, which posts a file to process.php. As the file is uploading, through a hidden iframe, I am polling the progress through the use of ajax. In my ajax callback php file, I am including my fileuploader.php, which contains the fileuploader class.
I then call a static method that checks the apc cache for the upload status, then writes it to a session variable, and returns. This information (from the session variable) is then relayed back to the upload page.
Once the uploading of the file is complete, process.php then creates a fileuploader object and calls the CompleteUpload method, which moves uploaded file to the appropriate location, etc.. then starts a thread via popen which processes the uploaded file from the new location.
It seems that once this popen command is executed, the current session hangs. I cannot view any page which uses sessions (however, if there is a page which does not use sessions at all, it is viewable).
Now this is where it gets kind of interesting. If I create a new file, lets call it test.php, and have a popen('start /b foo.exe', 'r'); it will run fine indefinetly without causing any problems. However, once the phenomenon is triggered via my upload script, that page will hang as well (even if it does not have any session handling). The file will only run again once apache is restarted.
I also logged into my server via RDP, and opened process explorer. When this behaviour occurs, there are child processes "cmd.exe and php.exe" listed under httpd.exe, but they are hanging, they have no PID, no information, nothing. And if I try to view their properties with process explorer, it crashes !
I then went back to that bug report (http://bugs.php.net/bug.php?id=22526) and tried the 'quick hack' that was described there once again (by doing a session_write_close before executing popen) , and sure enough, it worked ! I had tried it earlier with no avail, but I realized that I had tried it AFTER the behaviour occured, and it seems like once its triggered, apache must be restarted for it to return to normal, or else all exec, popen, or system commands will fail.
Althoug that thread is relatively old (php 4 ) it seems this issue is still there with 5, just that the conditions must be right for it to occur ?