php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36081 PHP Script continues to run after user hits "stop"
Submitted: 2006-01-19 12:20 UTC Modified: 2006-08-24 16:15 UTC
Votes:5
Avg. Score:4.8 ± 0.4
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:1 (25.0%)
From: bashusr at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.1.3, 4.4.2 OS: Windows 2003
Private report: No CVE-ID: None
 [2006-01-19 12:20 UTC] bashusr at gmail dot com
Description:
------------
When running a large script, php does not stop execution even after the stop button and the connection to the server is terminated.

Expected result:
----------------
PHP should stop when the "stop" button is pushed to save valuable resources...


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-19 12:29 UTC] tony2001@php.net
What's the value of `ignore_user_abort` directive in phpinfo() ?
 [2006-01-19 21:39 UTC] bashusr at gmail dot com
PHP Core

Directive Local     Value    Master Value 
ignore_user_abort     Off    Off
 [2006-01-19 22:24 UTC] bashusr at gmail dot com
I prefer to keep with php4 for backward compatibility. I would understand if no update to this was made because this is an old version, but this appears to be a bug that should be fixed even in php4.
 [2006-01-19 22:30 UTC] tony2001@php.net
We just want to know if it works in 5.1 or not.

 [2006-01-19 22:48 UTC] bashusr at gmail dot com
installed snapshot version as C:\php5, same results... Script continues after pushing stop on client browser.
 [2006-01-20 00:25 UTC] sniper@php.net
Does your script output anything..?
See also the user notes here:
http://www.php.net/manual/en/function.connection-aborted.php
 [2006-01-20 01:58 UTC] bashusr at gmail dot com
yes, my outputs data...

It pipes data through proc_open to a process in 8 or 16 kb chunks. It should stop sending data to my process and close it when the connection is aborted... I will try some tests with this function.
 [2006-01-20 08:10 UTC] sniper@php.net
Your page needs to output data to _browser_.
 [2006-01-20 08:12 UTC] bashusr at gmail dot com
yes, it does output data to the browser. My mistake, i forgot to mention that after the data is piped to the program, the stdout is piped into the browser.
 [2006-01-20 09:21 UTC] sniper@php.net
Try with some other script which does NOT pipe anything anywhere..
 [2006-01-20 14:25 UTC] bashusr at gmail dot com
I wrote a test script just for this purpose:

<?php

echo "hey";
$handler=fopen("tmp.txt","w");
while(true) {
    fwrite($handler, "Hey\n");
}
?>

The echo _should_ be enough to display data for connections aborted. In any case, i hit the "stop" button... and the script continues to run taking 100% cpu time and the tmp.txt grows indefinitely. 

In case it is of any use, I am on windows 2003 using php through ISAPI.
 [2006-01-20 14:45 UTC] tony2001@php.net
Does this code work for you?
<?php
$handler=fopen("tmp.txt","w");
while(true) {
    echo "hey";
    fwrite($handler, "Hey\n");
}
?>
 [2006-01-20 14:50 UTC] bashusr at gmail dot com
I get a lot of "hey"'s, then click "stop" on the browser and the script is still running in the background taking up 100% cpu and making temp.txt 10 MB large.
 [2006-01-20 15:56 UTC] sniper@php.net
Does it happen with Apache? (try it if you haven't done so yet)
 [2006-01-21 00:12 UTC] bashusr at gmail dot com
apache on windows? I do not have apache and do not have the ability to install it on this server. I know when I run similar scripts on apache under linux, I have no problems.
 [2006-01-21 01:56 UTC] sniper@php.net
Yes, Apache is also very easy to install on Windows.
You can get it from http://httpd.apache.org/
It's not only much better webserver than IIS, it actually works. :)
 [2006-01-21 02:00 UTC] bashusr at gmail dot com
If this is true, PHP documentation should have a note that it does not support IIS fully.
 [2006-04-28 08:08 UTC] bashusr at gmail dot com
Ok... I took Philip's advice from irc://irc.freenode.net/##php and actually ran the simple while(true) {} script in apache2 with the latest php snapshot... Same results, except apache2 seemed to respect the 30 second execution limits... This isn?t just an IIS bug if it makes anyone more inclined to fix it.
 [2006-07-27 02:09 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-07-28 05:19 UTC] bashusr at gmail dot com
Using latest snapshot. Same issue.
 [2006-08-24 16:15 UTC] tony2001@php.net
PHP detects aborted connection if the underlying "write buffer to the client" call fails. If it doesn't fail and continues to write the data to nowhere, PHP can't do anything about it.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 20 18:00:03 2025 UTC