Exec randomly hangs / stalls
Posted on 2005-03-30
My environment is:
- PHP 4.3.10
- Apache 2.0.53
- Windows 2000 Server
- The Apache service is configured to run as "Local System account" with "Allow service to Interact with desktop" turned ON
I have a script that runs several commands via the exec() function. The script basically does something like this:
exec("MOVE someFiles tempDir");
exec("DIR tempDir /some switches",$CaptureDirOutput);
$fp = fopen("newBatchFile.bat","w");
exec("MOVE resultingFiles finalDir");
So there are 4 exec() calls in there. For about a week, this worked perfectly. When we ran the script, we could see the shells being opened and closed on the desktop. The script runs on a server that is nothing more than a little-used database server, so there have been no changes made to the server, really.
Suddenly, these same exec() calls started to hang. We can see the first shell window open (to move files), and it DOES execute the program (the files get moved), but then the shell just stays open and doesn't close down.
Again, nothing has changed that would affect the call. Sometimes the filename might be 123321.xml, and sometimes it will be 1439894.xml, or something like that. And the fact that the command actually runs (for instance, an exec("MOVE files newdir") call WILL actually move the files), means that it's something else.
The only other odd thing I've noticed is that I have 2 Apache.exe processes in my Task Manager - the first is taking up about 25,000k of memory, the second is just under 7,000k. But after restarting Apache, it still seems to create 2 processes (they just don't use as much memory yet).