[php-src] Issue #7910: rename fails on Windows PHP 8.1 if the target file is being executed

From: Date: Sat, 08 Jan 2022 15:22:56 +0000
Subject: [php-src] Issue #7910: rename fails on Windows PHP 8.1 if the target file is being executed
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238880@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/7910 Comment Author: cmb69 The file is opened in FILE_SHARE_DELETE mode, but apparently, moving an opened source file is possible, while moving to an opened destination file is not: ```` C:\php-sdk\phpdev\vs16\x64 $ echo foo>foo C:\php-sdk\phpdev\vs16\x64 $ echo bar>bar C:\php-sdk\phpdev\vs16\x64 $ type movefile.c #include <Windows.h> int main(void) { HANDLE file = CreateFileA( "bar", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); BOOL res = MoveFileExA( "foo", "bar", MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED); printf("%d", res); return 0; } C:\php-sdk\phpdev\vs16\x64 $ cl movefile.c Microsoft (R) C/C++-Optimierungscompiler Version 19.29.30138 für x64 Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten. movefile.c Microsoft (R) Incremental Linker Version 14.29.30138.0 Copyright (C) Microsoft Corporation. All rights reserved. /out:movefile.exe movefile.obj C:\php-sdk\phpdev\vs16\x64 $ movefile.exe 0 C:\php-sdk\phpdev\vs16\x64 $ type foo foo C:\php-sdk\phpdev\vs16\x64 $ type bar bar ```` I think we either need to close the script file right after compilation, or accept that this is just not supported on Windows. I'd prefer to do the former, unless there is a good reason to keep the script file open.

« previous php.bugs (#238880) next »