Bug #81259 [Opn]: Long execution causes unlink function to give wrong result

From: Date: Thu, 15 Jul 2021 11:42:36 +0000
Subject: Bug #81259 [Opn]: Long execution causes unlink function to give wrong result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235046@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81259&edit=1 ID: 81259 User updated by: raincomplain at outlook dot com Reported by: raincomplain at outlook dot com Summary: Long execution causes unlink function to give wrong result Status: Open Type: Bug Package: Filesystem function related Operating System: Windows -PHP Version: 7.3.29 +PHP Version: 7.3 Block user comment: N Private report: N New Comment: Version 7.3 Previous Comments: ------------------------------------------------------------------------ [2021-07-14 22:45:05] raincomplain at outlook dot com Description: ------------ As you know on Windows as of PHP 7.3 it is possible to unlink() files with handles in use (no need to close the handle). To do that it seems to me that PHP trys to (delay) unlinking until program execution ends(which is the problem). Unlinking files in the past when a file handle is open was not possible at all, however as of 7.3 unlink() returns true even though the file is not deleted yet. The test script shows that we can do things (creating data2.txt) even when the program is not correct yet (data.txt has to wait 10 seconds to be removed). Test script: --------------- $fp= fopen('data.txt', 'r'); if (unlink('data.txt')) { fopen('data2.txt', 'w'); } sleep(10); Expected result: ---------------- . .. data2.txt Actual result: -------------- . .. data.txt data2.txt ( for 10 seconds) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81259&edit=1

« previous php.bugs (#235046) next »