Bug #51802 [Opn->Fbk]: PHP temp files not deleted when also using a CGI script
| From: | felipe@php.net | Date: | Tue, 15 Nov 2011 15:43:30 +0000 |
| Subject: | Bug #51802 [Opn->Fbk]: PHP temp files not deleted when also using a CGI script | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-165164@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=51802&edit=1
ID: 51802
Updated by: felipe@php.net
Reported by: relayadmin at disney dot com
Summary: PHP temp files not deleted when also using a CGI
script
-Status: Open
+Status: Feedback
Type: Bug
Package: CGI/CLI related
Operating System: Windows Server 2003
PHP Version: 5.2.13
Block user comment: N
Private report: N
New Comment:
Please try using this snapshot:
http://snaps.php.net/php5.3-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
Previous Comments:
------------------------------------------------------------------------
[2010-05-12 21:07:14] relayadmin at disney dot com
Description:
------------
This bug is very specific to Windows. When executing a generic file upload using PHP, if at anytime
while the file is being uploaded Apache then runs a CGI script like PERL or a C program, and the
upload ends while the CGI script is still running, the uploaded file(s) in the temp directory will
remain behind forever.
In order to avoid this the âphp_do_open_temporary_fileâ routine will have to not use the
âVCWD_OPEN_MODEâ routine to open the temp file. A generic Windows âopenâ call
allows child processes to inherit their handles. The temp file would need to be opened with a
âCreateFileâ call to open the file and specify the pSecurityAttributes option with
bInheritHandle set to FALSE so that a child process will not inherit the open file handle. The rub
is this call uses a non-compatible handle so everyone who uses this handle has to be modified as
well.
Test script:
---------------
Write or use any simple PHP upload program. Next use CGI program below -- it doesn't need to
do anything except take time. So start the PHP upload, then start the CGI program below from a
webpage. Make sure the PHP upload completes before the script ends.
#include <windows.h>
void main(){
Sleep(2*60*1000); // sleep 2 minutes
}
Expected result:
----------------
The file should be uploaded and the temp file in the temp directory should not be present when done.
It should be moved to the destination directory.
Actual result:
--------------
The temp file remains forever in the temp directory, though the file is copied correctly to the
destination directory.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=51802&edit=1