Edit report at http://bugs.php.net/bug.php?id=44942&edit=1
ID: 44942 Comment by: richard at dlconsulting dot com Reported by: inqualab1985 at gmail dot com Summary: exec() hangs apache Status: No Feedback Type: Bug Package: Program Execution Operating System: Windows 2000 SP4 PHP Version: 5.2.5 Block user comment: N New Comment: Had a similar problem which was reproducible on Apache 1.3.26 and PHP 5.2.14 or PHP 5.3.3, (Apache running on Windows XP SP3). Reproducable when using Firefox 3.6.8, Chrome 5.0.375.127, IE 8.0.6001.18702 Interestingly, when the same PHP based system was running on linux (Centos 5.5) this problem could not be reproduced. A parent browser window opens a child popup to perform an import process of some files into a system. The child popup window is running a PHP script which as part of its process calls an external binaries such as rm.exe or unzip.exe binary using the exec function. As part of the html in the child popup window, we call a javascript function with <script type="text/javascript">window.opener.location.reload();</script> which reloads the parent window (which is also generated via PHP). When this bug occurs, the JavaScript above is near the top of the web page, so that it seems to trigger a reload of the parent PHP script during the child popup PHP process, and apparently this interferes somehow with the execution of the child popup PHP process, because when we tried moving this JavaScript to the bottom of the popup PHP process webpage . . the problem goes away. This problem, which seems somehow related to the concurrent execution of the PHP of the parent browser window, hangs Apache completely. Apache has to be terminated manually, and then restarted. Therefore this bug was a showstopper until we happened upon a work-around. If we remove calls to exec() in the child popup PHP script, the problem disappears. The duration of the child popup PHP script is not trivial, it might unzip / read / move maybe 50 files (although on fast hardware this might take less than a second anyway . . .) Previous Comments: ------------------------------------------------------------------------ [2010-09-06 14:53:26] elwiz at 3e dot pl Hello. I am also having the same problem. One of my scripts is being called multiple times (as a SRC for image tags) and each time it uses the exec function. On windows XP, with PHP 5.2.5 and Apache 2.2 the PHP stops responding. Requests for static files can be done but PHP scripts run endlessly. Session closing and opening helps but it is still just a workaround. ------------------------------------------------------------------------ [2010-07-25 21:00:18] andy dot hilbig at clubsys dot co dot uk I have been plagued with PHP freezing after a few minutes, days or maybe weeks. I use exec() to link to custom vb.exe I have searched and searched until today tried the session_write_close(); before the exec()call and session_start (); after. I can now click [Next Day]/[Next Day] as fast as I like and all appears solid now. Other users have connected at the same time. So, thank you all very much for the cure. I have umpteen years programming in machine code and 15 in VB6 with the Jet engine to Access. All works well with Apache/PHP/VB exes. Do I really need .Net ??? ------------------------------------------------------------------------ [2009-08-27 10:00:24] listephp at andrioli dot com I've the same problem too. I tried the latest snapshot 5.2.11RC2-dev build date: Aug 26 2009 23:42:35 , but it shows up. Configuration - Windows 2003 R2 - Apache 2.2.11 Both, exec() running java.exe and system() running .NET program, hang Apache as described above. ------------------------------------------------------------------------ [2009-06-08 16:41:29] alex at bartl dot net Reproducable with PHP 5.2.9-1 on Windows2003 Server with Apache2.2 Workaround with calling session_write_close() before calling exec() confirmed working NOT reproducable with PHP 5.2.1 on Windows 2000 Server with IIS5 anyway, seems to be a duplicate of Bug#44994 ------------------------------------------------------------------------ [2009-04-07 15:12:50] gouldee at netscape dot com I am having the same or similar issue: OS: MS2003 PHP: 5.2.6 APACHE2: 2.2 The bug occurs with an PHP script that has a PHP passthru exec call that hangs every now and then. After the first hang occurs then any passthru call hangs in the same manner. I believe that the passthru call runs as I am calling a sendmail.exe process that does send the E-Mail, however, the Browser page hangs after the E-Mail has been sent by sendmail.exe called via passthru(). There are no PHP or Apache2 errors or warnings. It seems that the problem happens when (2) calls to the same .exe happens at the same time, but, I have no real proof of this, as I can't provide execution times for each instance of the sendmail.exe running. This is a serious problem, as all pages that call an .exe process after the initial hang will hang up as well. I can clear the bug by simply stopping and restarting the Apache service. I also note that If I run the page, that hangs up, manually in a Command Prompt DOS window like: D:\php page.php there are no hangs and the process performs correctly even during and after the first showing of the bug. So the problem seems to be when PHP does an exec call in conjunction with Apache, as I said even during the time a hang occurs I can still exec passthru commands from a command prompt. I can also run any page that calls PHP as long as the page does not have any exec or passthru calls in it, and all pages with HTML only runs fine as well during the hang period. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=44942 -- Edit this bug report at http://bugs.php.net/bug.php?id=44942&edit=1