|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73039 Temporary files not being cleaned up when shell_exec called
Submitted: 2016-09-07 12:56 UTC Modified: 2020-03-22 04:22 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: chu_man_fu at hotmail dot com Assigned: cmb (profile)
Status: No Feedback Package: Streams related
PHP Version: 5.6.25 OS: Windows Server 2012 R2
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-09-07 12:56 UTC] chu_man_fu at hotmail dot com
I have noticed the temp directory on the web server is full of files named php*.tmp.
The contents of these files is POST data for various ajax calls (mainly the same group of calls). There isn't a temp file per call. If I watch the directoy I can see most temp files appear and then get deleted. However, for whatever reason, sometimes these files are not cleaned up.
The only way I have been able to reproduce this error is using apache bench to post data (26KB) to a script which uses the shell_exec, exec, popen command:



echo "FINISHED";


It will only produce the temp file when there is concurrency and lots of requests for each:

ab -p <post_data_file> -c 3 -n 30 <url_to_script>

Our system does perform calls to popen() but the POST data temp files which are being left behind are not always for calls which invoke this function.

I can produce the issue on 5.6.24 and 5.6.25.
I have tried on the following versions and not been able to reproduce it: 5.4.44, 5.5.25, 7.1

I not beein able to reproduce the issue on a Mac running 5.6.18.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-08 13:19 UTC]
-Status: Open +Status: Feedback
 [2016-09-08 13:19 UTC]
Thanks for the report. Could you please check error logs? Or the event log, if applicable. I see no direct connection to shell_exec, except a command would run over the timeout limit and cause a premature script bailout.

 [2016-09-09 14:56 UTC] chu_man_fu at hotmail dot com

We get no errors or events and the script doesn't acutally bail out. It carries on but the temp file is never cleaned up.
I have changes the script so that shell_exec is calling CLS rather than DIR and I get the same problem.

 [2016-09-13 15:09 UTC]
-Status: Feedback +Status: Open
 [2016-09-19 09:13 UTC] chu_man_fu at hotmail dot com

Has anyone been able to replicate this yet?

 [2017-12-05 08:09 UTC] chu_man_fu at hotmail dot com
Does anyone know if this is going to be fixed in 5.6?
We are currently stuck on 5.6 due to issues to ZTS for 7.1 and mcrypt being pulled from 7.2.
 [2020-03-10 10:39 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-03-10 10:39 UTC]
Do you still experience this issue with any of the *actively*
supported PHP versions[1]?

FWIW, mcrypt is available via PECL[2].

[1] <>
[2] <>
 [2020-03-22 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Aug 04 02:01:23 2021 UTC