4 ms·
I keep forgetting Windows-isms that won't allow you to delete the executable file of a running process. I guess that's also why the arcane .dll upgrade process
by tankenmate 3y ago
I keep forgetting Windows-isms that won't allow you to delete the executable file of a running process. I guess that's also why the arcane .dll upgrade process / WoW is so necessary.
- deleted 3y ago[deleted]
- xxs 3y ago>won't allow you to delete the executable file Any open file
- anticensor 3y agoTne kernel actually allows for that, but Win32 apparently does not.
- spatulon 3y ago> Any open file Any file that was opened without specifying FILE_SHARE_DELETE in the call to CreateFile[1] (the Win32 equivalent of open(2)). Unfortunately, most language runtimes that wrap CreateFile tend not to pass that flag. [1] https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew https://learn.microsoft.com/en-us/windows/win32/api/fileapi/...
- nextaccountic 3y agoCan a running executable start with this flag, so that its file can be removed?
- dist-epoch 3y agoProbably not, since Windows uses the executable file as backing for memory mapping.
- xxs 3y agoindeed - also reminds me that languages like go[0] and java[1] did disagree to even attempt using it [0]: https://github.com/golang/go/issues/32088#issuecomment-537590826 https://github.com/golang/go/issues/32088#issuecomment-53759... [1]: https://bugs.openjdk.org/browse/JDK-6607535 https://bugs.openjdk.org/browse/JDK-6607535 So to me it's just not there...
- mananaysiempre 3y agoApparently some parts of this are quite recent, huh[1]: > jstarks commented on Jun 18, 2019: > [I]n the most recent version of Windows, we updated DeleteFile (on NTFS) to perform a "POSIX" delete, where the file is removed from the namespace immediately instead of waiting for all open handles to the file to be closed. [1] https://github.com/golang/go/issues/32088#issuecomment-502850674 https://github.com/golang/go/issues/32088#issuecomment-50285...
- ChrisSD 3y agoNotably Rust's standard library does allow deleting files it opens by default. https://github.com/rust-lang/rust/blob/735bb7e5df185cc24e56533abd0bbab510931f6f/library/std/src/sys/windows/fs.rs#L190C19-L190C19 https://github.com/rust-lang/rust/blob/735bb7e5df185cc24e565... While full Unix-like behaviour is only available on Windows 10 for the past five or so years, you can still have the old win32 behaviour on older systems (delete once the last file handle is closed).
- the8472 3y agoI don't think that's true any longer. Windows now defaults to setting FILE_DISPOSITION_POSIX_SEMANTICS https://stackoverflow.com/q/60424732/1362755 https://stackoverflow.com/q/60424732/1362755
- grishka 3y agoBut there must be an API to unlock files that programs like "The Unlocker" use? Or do they just enumerate the other processes handles to that file and close them?
- cesarb 3y ago> Or do they just enumerate the other processes handles to that file and close them? AFAIK, that's exactly what they do. And it can cause problems, see for instance https://learn.microsoft.com/en-us/previous-versions/technet-magazine/dd547078%28v=msdn.10%29 https://learn.microsoft.com/en-us/previous-versions/technet-...
- prmoustache 3y agoIt is probably one of the reason windows ask so very often to be rebooted for any minor change.
- vb6sp6 3y ago[dead]