News for hackers. Stuff that matters.
Re:Windows Subsystem for Linux: The lost potential by m_mueller on Friday November 20, 2020 @03:43AM (#25158528)
so what's the 'Windows way' then? keeping a file open forever and let it lock out other programs from using that file? I'm starting to get an idea why Windows is getting on my nerves so much with file locks....
Re:Windows Subsystem for Linux: The lost potential by pjmlp on Friday November 20, 2020 @06:52AM (#25159581)
Here is the thing, UNIX is the strange dude with advisory file locks, every other multiuser OS does the right thing to avoid file corruption.
Re:Windows Subsystem for Linux: The lost potential by for_xyz on Friday November 20, 2020 @06:40AM (#25159508)
> so what's the 'Windows way' then?

Using either memory mapped files of overlapped io (IOCP).

It's tricky to use when you want to write the content since you must preallocate the file before you start with the writing. Appending to file just doesn't work under NT kernel since WriteFile blocks even if you use overlapped io.

Devs just need different mentality when it comes to Windows programming compared to Linux. Due the fact that everything under NT kernel is operated asynchronously you'll have to adapt your code to such concept. Meanwhile under Linux you had no other alternative for nearly 30 years (io_uring and friends) so if you wanted to be portable with minimum OS specific code then you had to implement things in synchronous way or write two separate code paths for each OS.

Guess which one is used in practice.

Re:Windows Subsystem for Linux: The lost potential by mehrdadn on Friday November 20, 2020 @04:00AM (#25158633)
You can just use FILE_SHARE_WRITE if you don't want to lock out other programs...
Re:Windows Subsystem for Linux: The lost potential by VBprogrammer on Friday November 20, 2020 @04:57AM (#25158962)
If I know one thing about files it's that any fix beginning with "You can just..." is probably wrong.

https://danluu.com/file-consistency/

Re:Windows Subsystem for Linux: The lost potential by mehrdadn on Friday November 20, 2020 @05:00AM (#25158969)
I didn't recommend you do this, I just said it's there if you really want to.