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

From: Date: Thu, 15 Jul 2021 11:55:49 +0000
Subject: Bug #81259 [Com]: Long execution causes unlink function to give wrong result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235048@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
 Comment 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
 Block user comment: N
 Private report:     N

 New Comment:

This bug started at 7.3 and is reproducible in version 8


Previous Comments:
------------------------------------------------------------------------
[2021-07-15 11:45:18] rtrtrtrtrt at dfdfdfdf dot dfd

https://www.php.net/supported-versions.php

------------------------------------------------------------------------
[2021-07-15 11:42:36] raincomplain at outlook dot com

Version 7.3

------------------------------------------------------------------------
[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


Thread (9 messages)

« previous php.bugs (#235048) next »