From: datacompboy at mail dot ru
Operating system: Win2003 adv server
PHP version: 4.3.3
PHP Bug Type: cURL related
Bug description: Not closing download handles

Description:
------------
I tried to download file with curl, p it with external app, show
output and kill temp file. But:
1. if php as isapi module - when several requests at one time some inputs
are locked! Filemon says that it frees by some cmd.exe after all runned
sub-processes already finished. Very strange!
2. if php as fastcgi - it often crashes with error in php_curl (all latest
dlls in system32 upgraded; php4ts only in c:\php, php4isapi also in c:\php
and no in c:\windows\system)
3. if php as cgi - all OK, except of when user cancelled download the
script terminated, but shotdown_procedure not called, so temp files left.

Reproduce code:
---------------
<?ob_start(); $url="http://some.site.com";
$oinfile = tempnam ("./", "URLIN");
$infile = preg_replace("#.*[/\\\\](.*?)#","\$1",$oinfile);
$ooutfile = tempnam ("./", "URLOU");
$outfile = preg_replace("#.*[/\\\\](.*?)#","\$1",$ooutfile);
register_shutdown_function(create_function('',
"unlink(\"$infile\"); unlink(\"$outfile\"); unlink(\"$oinfile\");
unlink(\"$ooutfile\"); return 1;"));
$inf = fopen($infile, "w");
fwrite($inf, "<meta http-equiv=\"Content-Type\"
content=\"text/html\">\n");
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_FILE, $inf);
$st=curl_exec ($ch);
curl_close ($ch);
fclose($inf);
echo `filter.exe $lang $infile $outfile 2>&1`;
ob_end_flush();
?>

Expected result:
----------------
No .tmp files not in windows\temp\ folder, not in script folder.

Actual result:
--------------
Some .tmp files left and in windows\temp, and in script folder.

--
Edit bug report at [url]http://bugs.php.net/?id=26060&edit=1[/url]
--
Try a CVS snapshot (php4): [url]http://bugs.php.net/fix.php?id=26060&r=trysnapshot4[/url]
Try a CVS snapshot (php5): [url]http://bugs.php.net/fix.php?id=26060&r=trysnapshot5[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=26060&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=26060&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=26060&r=needtrace[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=26060&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=26060&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=26060&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=26060&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=26060&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=26060&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=26060&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=26060&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=26060&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=26060&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=26060&r=float[/url]