Bug #77365 [Opn->Nab]: tmpfile() is not being cleaned up
| From: | cmb@php.net | Date: | Fri, 12 Feb 2021 14:16:15 +0000 |
| Subject: | Bug #77365 [Opn->Nab]: tmpfile() is not being cleaned up | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-232090@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77365&edit=1
ID: 77365
Updated by: cmb@php.net
Reported by: gadelat at gmail dot com
Summary: tmpfile() is not being cleaned up
-Status: Open
+Status: Not a bug
Type: Bug
Package: Filesystem function related
Operating System: Ubuntu 18.04
PHP Version: 7.2.14RC1
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This is expected behavior. The respective documentation has been
fixed in the meantime.
> There is no way in PHP to clean up tmpfiles when script is
> terminated with ctrl+c in cross platform compatible way :(
Well, at least there is a way on Windows as well:
<?php
$stream = tmpfile();
sapi_windows_set_ctrl_handler(function ($event) {exit;});
while(true);
?>
Previous Comments:
------------------------------------------------------------------------
[2018-12-30 14:28:43] spam2 at rhsoft dot net
ctrl+c = sigterm and so why should there be no way?
------------------------------------------------------------------------
[2018-12-30 09:33:14] gadelat at gmail dot com
There is no way in PHP to clean up tmpfiles when script is terminated with ctrl+c in cross platform
compatible way :(
------------------------------------------------------------------------
[2018-12-30 00:01:08] gadelat at gmail dot com
Just found that following for some reason DOES delete the file
<?php
$stream = tmpfile();
pcntl_async_signals(true);
pcntl_signal(SIGINT, function() {
exit(0);
});
while(true);
------------------------------------------------------------------------
[2018-12-28 18:00:49] gadelat at gmail dot com
Description:
------------
Might be duplicate of https://bugs.php.net/bug.php?id=67105 but created
this issue anyway, since that report wasn't acknowledged and aims for documentation instead of
fixing the cleanup process.
Anyway, bug is that interrupting script via CTRL+C prevents tmpfile cleanup.
Test script:
---------------
tmpfile(); while(true) // execute this and press ctrl+c
Expected result:
----------------
no new php* files in /tmp/
Actual result:
--------------
new php* file in /tmp/
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77365&edit=1