|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2018-12-28 18:00 UTC] 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/ PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 10:00:02 2025 UTC | 
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);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); ?>