News for hackers. Stuff that matters.
Re:Windows is the strangest, or hardest, operating system to... by elzbardico on Wednesday November 30, 2022 @07:21AM (#33799693)
NT is different from Unix, it is heavily inspired by VMS, which was the anti-Unix of its time. The basic architectural metaphors are different, and the way you think about things is different. It is more architectured and more opinionated, which may look like over-engineering for some and a superbly coherent design for others. There are some pain points, of course, a lot of them related to the need to support code written for a completely different OS (MS-DOS + Windows non-nt), but overall, I think that the general architecture of NT is pretty neat, and I would dare say, beautiful in some places.
Re:Windows is the strangest, or hardest, operating system to... by AdamN on Wednesday November 30, 2022 @08:25AM (#33800345)
This is really the New Jersey approach vs the MIT approach:

https://www.jwz.org/doc/worse-is-better.html

Re:Windows is the strangest, or hardest, operating system to... by ilyt on Wednesday November 30, 2022 @09:02AM (#33800862)
It appears that author does not like HN as this redirects to https://cdn.jwz.org/images/2016/hn.png

Is that the same wanker that got in a hissy fit over distros including xscreensaver ?

Re:Windows is the strangest, or hardest, operating system to... by gpderetta on Wednesday November 30, 2022 @09:08AM (#33800939)
He is indeed the same JWZ!
Re:Windows is the strangest, or hardest, operating system to... by teddyh on Wednesday November 30, 2022 @10:52AM (#33802473)
Better link (from the actual author of the text, and without referrer tricks for links from HN): https://dreamsongs.com/RiseOfWorseIsBetter.html
Re:Windows is the strangest, or hardest, operating system to... by galangalalgol on Wednesday November 30, 2022 @08:41AM (#33800556)
One thing I have trouble with in windows is debugging problems. If say I plug in a usb device and nothing happens, I know what logs to look at, and they are verbose and if I don't, I can search the internet and find five or six possible solutions depending on distro and age. In windows the search generally says "download this malware and it will solve your problem", "restore to a save point" or "grab your install media and start over". I would be surprised if there is a good way to do the same things, they just aren't discoverable. When the device manager and services.msc show all is well, but it clearly isn't, there doesn't seem to be much advice out there.
Re:Windows is the strangest, or hardest, operating system to... by ethbr0 on Wednesday November 30, 2022 @09:26AM (#33801166)
It's absolutely a problem. Aka the sysinternals / Bryce Cogswell and Mark Russinovich problem.

To wit, Windows has plenty of debugging functionality. Historically not as extensive as Unix, but it was there.

However, 0% of that was exposed in any sane way, because Microsoft...? Actually, I have no idea why it wasn't. For the price of 2 senior engineers and a willingness to actually release tools, Microsoft could have drastically improved the situation.

Instead they just (eventually) bought sysinternals. :(

Re:Windows is the strangest, or hardest, operating system to... by galangalalgol on Wednesday November 30, 2022 @09:33AM (#33801248)
Do you have a good reference point for me to start learning that stuff? I use linux almost exclusively, but it bites me often enough it is worth a few days to self educate.
Re:Windows is the strangest, or hardest, operating system to... by ethbr0 on Wednesday November 30, 2022 @11:35AM (#33803243)
Event Viewer has gotten a lot better over the years for surface-level stuff, but is still summary only. Which in no way mimics the *nix verbosity. I'll see if I can find a good entry point.
Re:Windows is the strangest, or hardest, operating system to... by isignal on Wednesday November 30, 2022 @11:45AM (#33803382)
For logs, Windows has a standard events mechanism that many apps and the kernel itself uses. So windows event viewer is the equivalent of journalctl logs for specific services.

But the gui is kind of heavy and not at all like opening a text file in less.

Re:Windows is the strangest, or hardest, operating system to... by xnyan on Wednesday November 30, 2022 @12:12PM (#33803816)
There's a gui for viewing events, but you probably want to use the cli for debugging: https://learn.microsoft.com/en-us/windows-server/administrat...

If you're learning, start with the official windows docs. They are often very good.

Re:Windows is the strangest, or hardest, operating system to... by boris on Wednesday November 30, 2022 @09:07AM (#33800922)
> superbly coherent design [...] NT is pretty neat, and I would dare say, beautiful in some places

Practically, though, it's a shit show. My "favorite" is the inability to delete a file that is open by another process. Combine this with Windows Defender that scans every file that your application creates, and now you have no reliable way of deleting or moving your files.

As someone who works on a C/C++ build toolchain and has to deal with Windows design decisions every day, I can tell you without any hesitation there is nothing coherent or beauatiful about it. I don't think even Microsoft believes this.

Re:Windows is the strangest, or hardest, operating system to... by 323 on Wednesday November 30, 2022 @09:32AM (#33801237)
> My "favorite" is the inability to delete a file that is open by another process

Because of this Linux "feature" I experienced data loss - I zipped a file and deleted it, but the process which created it was still writing to it. But all the data that it wrote now ended up in the void since the file didn't exist anymore. And there was no error/warning that the process was writing to a non-linked file, so I discovered the data loss much later.

Re:Windows is the strangest, or hardest, operating system to... by codedokode on Wednesday November 30, 2022 @09:35AM (#33801273)
Because the file was actually existing, but removed from directory list.
Re:Windows is the strangest, or hardest, operating system to... by iso1210 on Wednesday November 30, 2022 @10:56AM (#33802530)
And you can still access it while it's open from the /proc directory
Re:Windows is the strangest, or hardest, operating system to... by P5fRxh5kUvp2th on Wednesday November 30, 2022 @09:37AM (#33801313)
you CAN lock files under linux, it's just not the default.
Re:Windows is the strangest, or hardest, operating system to... by shakow on Wednesday November 30, 2022 @09:44AM (#33801398)
But locks are suggestive, not mandatory. So if the other process does not take them into account, they just have no effect.
Re:Windows is the strangest, or hardest, operating system to... by chasil on Wednesday November 30, 2022 @10:33AM (#33802090)
Mandatory locking has profound security impacts.

I can update glibc or other core system libraries on Linux without rebooting. Processes using the old library will show "(deleted)" in their /proc/self/maps files, but they will continue to use the old code. New processes will use the new library, and downtime was not required.

This is not possible on Windows because of mandatory locking on core system libraries. As a consequence, Windows must reboot for every Patch Tuesday.

There are only a few places that Linux has mandatory locking, and this is a good thing.

Re:Windows is the strangest, or hardest, operating system to... by 323 on Wednesday November 30, 2022 @11:16AM (#33802907)
I don't know about Windows core system libraries, but for user libraries you can do the same thing - rename old library, and put new library in it's place. Running processes will continue using the old library, and new ones will pick up the new library. The only difference is that instead of deleting the old library you need to rename it (and then delete it later).

Linux doesn't need reboots only in theory. I have an Ubuntu server box and not a week passes in which I don't see a "system reboot is required" prompt when I SSH into it.

Re:Windows is the strangest, or hardest, operating system to... by P5fRxh5kUvp2th on Wednesday November 30, 2022 @11:34AM (#33803206)
then stop updating the kernel once/week.

There are mechanisms for updating the kernel in-place, and I believe canonical is one of the leaders in that domain, but if you're choosing not to use it and you don't want to reboot once/week, you can still keep your system level libraries up to date without rebooting.

The above poster didn't say you could update absolutely everything in linux without a reboot, just that the locking mechanisms in windows means you have to reboot to update things that don't require a reboot in linux.

Re:Windows is the strangest, or hardest, operating system to... by 323 on Wednesday November 30, 2022 @12:35PM (#33804278)
I didn't choose anything, it's the default Ubuntu 22 image from a big cloud provider. They enabled auto-updates, including for the kernel. They didn't enable whatever update kernel in-place mechanism Ubuntu has. I assume they know what they're doing.

My point was that in theory Linux doesn't need reboots and Windows does, but in practice my Ubuntu box needs a weekly reboot, while my Windows box just once a month.

Re:Windows is the strangest, or hardest, operating system to... by P5fRxh5kUvp2th on Wednesday November 30, 2022 @01:41PM (#33805472)
There was never any theory that Linux doesn't need reboots to update the kernel. That's never been a general understanding in the more than 20 years that I've personally been working with Linux.

What's true is that you can update everything BUT the kernel without a reboot.

Any understanding of theory that involved a belief that Linux never needed a reboot to update the kernel is a flaw in your understanding rather than a problem with the theory.

And in fact, the reason people have been working on being able to update the kernel without a reboot is finally put to rest that final mile. Personally I don't think it will ever come to full fruition, but the list of things that does require a reboot will become smaller and smaller over time.

https://cloud7.news/article/how-to-update-linux-kernel-witho...

> Rebootless Kernel updates are not a replacement for full kernel upgrades but it allows you to patch critical security vulnerabilities and bug fixes. With these methods, you can keep your servers safe and running without outage for years.

> Several Linux vendors offer rebootless kernel updates. Your solution mostly depends on the distribution you are running.

And finally, a bit more info about canonical's solution

https://cloud7.news/article/how-to-update-linux-kernel-witho...

Re:Windows is the strangest, or hardest, operating system to... by 323 on Wednesday November 30, 2022 @03:41PM (#33807354)
> There was never any theory that Linux doesn't need reboots to update the kernel.

Yet people keep saying that on HN, that unlike Windows, you don't need to reboot Linux after updating, and then maybe mention how they have months of uptime.

By default Ubuntu, the most popular distro, updates the kernel too. And frequently the kernel update is a security update.

Re:Windows is the strangest, or hardest, operating system to... by P5fRxh5kUvp2th on Wednesday November 30, 2022 @04:29PM (#33808010)
What you're trying to imply here is that linux effectively needs to be reboot on every update, and you're wrong.

It's possible your cloud provider has chosen to have its own package repository where they insist on doing this, but this is a decision by your cloud provider and not Canonical.

Linux has what's called Kernel Modules that can be unloaded and loaded at runtime without the need to update the kernel itself. I myself run ubuntu in vmware, and have done so for probably over 10 years, and your description of Ubuntu's default behavior is inaccurate.

---

But more than that, it's been explained to you, stop arguing.

Re:Windows is the strangest, or hardest, operating system to... by P5fRxh5kUvp2th on Thursday December 01, 2022 @10:03AM (#33817106)
Actually, I'm going to add to my earlier reply here.

The amount of harm "security" people have wrought to everyone else around them is astronomical.

I don't doubt your cloud provider made that decision, it's yet another example of security people forcing major inconveniences on everyone else in the name of protecting them. It might even be warranted here (it probably is), but I would almost put money on 85-90% of terrible situations in software dev having a root in a security person somewhere. That sounds outlandish, yet it completely matches my experience.

Re:Windows is the strangest, or hardest, operating system to... by chasil on Wednesday November 30, 2022 @11:27AM (#33803089)
Right - POSIX is generally "advisory locking" rather than "mandatory locking," so an update process is free to overwrite any library.

Windows does not allow this, which is why we have Patch Tuesday outages.

Re:Windows is the strangest, or hardest, operating system to... by WorldMaker on Wednesday November 30, 2022 @03:42PM (#33807365)
Also, in theory Windows doesn't need reboots because like you said, the rename and replace works just fine for hot patches. Windows reboots as often as it does in part for "backwards compatibility" and the long tail of applications built under the broken 90s assumption that windows "doesn't" hot patch things.

Linux assumes that long running processes just randomly exploding because they are living in a pre-hotfix ghost state is fine (and usually free of security concerns). Windows assumes users notice and get frustrated when long running apps start acting "weird" and don't know why and that there are too many security implications if you just leave unpatched apps running alongside patched ones.

It's another one of those things on the list that the NT Kernel has the raw design to do a lot of smart, deliberate things, but at the end of the day can't trust user space to play nice with them happening and is maybe a little too safety conscious of that.

(My understanding too is that Ubuntu is an interesting example here because Canonical now explicitly uses a more Microsoft-influenced security model in user-focused distributions for when to require reboots. Under the same general concerns: avoid user-noticeable "weirdness" and avoid unpatched CVEs remaining long running in user space. While it could just kill unpatched processes, that creates "user noticeable weirdness", and for better and worse a full "restart" is much less shocking to the average user than long running processes getting killed "weirdly".)

Re:Windows is the strangest, or hardest, operating system to... by Karellen on Wednesday November 30, 2022 @09:44AM (#33801395)
But if the zip process had happened a bit quicker, the delete would have worked on either platform. Getting the error on Windows would only have been due to a race you could never guarantee would work out in your favour.

So, you experienced data loss because you deleted a file you didn't mean to.

...and?

Re:Windows is the strangest, or hardest, operating system to... by 323 on Wednesday November 30, 2022 @09:47AM (#33801450)
I don't understand what race on Windows, when you open a file for writing it's (typically) protected against deletion until you close it.

In the example I gave, the other process was continuously writing to this file while I was zipping it.

Re:Windows is the strangest, or hardest, operating system to... by Karellen on Wednesday November 30, 2022 @09:58AM (#33801606)
The race is between the process writing the zip file, and you trying to delete it.

If the process creating the zip file runs faster, and finishes, and closes the file, your attempt to delete it would have worked anyway. Because the program that created it didn't have it open any more.

Re:Windows is the strangest, or hardest, operating system to... by 323 on Wednesday November 30, 2022 @10:44AM (#33802300)
The program which created the file was running all the time, before I created the zip, during the zip creation, after the zip creation ended, and after I deleted the file.

The zip creation and me deleting the file were in parallel with another process writing to the file.

And I didn't delete the zip file, I deleted the original file that I zipped.

Re:Windows is the strangest, or hardest, operating system to... by Karellen on Wednesday November 30, 2022 @11:08AM (#33802754)
> And I didn't delete the zip file, I deleted the original file that I zipped.

OK, I think that's where a lot of the confusion comes from.

When you originally said "I zipped a file and deleted it, but the process which created it was still writing to it.", I thought the "it"s referred to the zip file, not the original file, and "the process that created it" was the zip process.

Going by your actual meaning - are you saying you zipped a file on disk that was still being written to? That's... weird.

Given that reading from disk is faster than writing to it, and the written data may well have been in the disk cache anyway, it's likely that the zip program could have "caught up" with the program that was writing the data, tried another read and been told "this is the end of the file", and then finished creating the zip file. That would have created an incomplete zip.

But also, as others have pointed out, just because you delete a file and it gets removed from the directory, the actual file and its contents stay around until all open handles to it are gone. So if one process has the file open and is writing to it, and a second process has the file open and is reading from it, if you delete the file then both processes should still be able to access it through their existing file handles, even though it doesn't have a directory entry any more. So you shouldn't have experienced any data loss from that series of events.

(And that's why having the "it"s refer to the zip file is a logical interpretation of what you said, and why a few repliers - including me! - seem confused)

Re:Windows is the strangest, or hardest, operating system to... by 323 on Wednesday November 30, 2022 @11:23AM (#33803019)
> Going by your actual meaning - are you saying you zipped a file on disk that was still being written to? That's... weird.

That's how Linux works. Some programs, like rsync, will give you a warning at the end, similar to "the file was modified during the rsync operation". Most others, like zip will give no warning at all.

Re:Windows is the strangest, or hardest, operating system to... by Karellen on Wednesday November 30, 2022 @02:33PM (#33806317)
Sorry, I wasn't clear. I didn't mean it was weird that Linux would be able to do that. I meant I thought it was weird that a user would choose to do that. Because without any co-ordinated locking in place, or double-checking at the end (which most won't unless it's been specifically added), having one program read a file while another is modifying it will most probably produce confusing or unexpected results.
Re:Windows is the strangest, or hardest, operating system to... by trelane on Wednesday November 30, 2022 @11:08AM (#33802744)
> I didn't delete the zip file, I deleted the original file that I zipped.

This is why you should always check the contents of your archive before deleting the originals. There are myriad reasons why the archive may be incomplete or incorrect. You were hit by one of them that happens to not happen on Windows.

Re:Windows is the strangest, or hardest, operating system to... by Bilal_io on Wednesday November 30, 2022 @09:47AM (#33801446)
This is hardly Linux's fault, nor its responsibility. As far as I know Linux gives you mechanism to lock files and directories, so the compression program you used should have locked the directory by default until it was done or canceled. And if that option was not the default in the program you've used, it could be present as an optional flag.

Someone with more knowledge please correct me if I got the above wrong.

That being said, the issue with Windows is that it prevents me from deleting a file if it's open in a text editor or any program, which should not be the default in my opinion. A directory gets locked simply because you have explorer open in that path, or a terminal cd'd into that path, which is annoying and counter productive most of the time.

Re:Windows is the strangest, or hardest, operating system to... by cesarb on Wednesday November 30, 2022 @09:54AM (#33801552)
> As far as I know Linux gives you mechanism to lock files and directories, so the compression program you used should have locked the directory by default until it was done or canceled.

File locking on Linux is advisory, it excludes other processes which try to lock the same region of the same file, but not operations other than locking. Mandatory locks were optional (required a mount option, see https://lwn.net/Articles/667210/ for details), and were removed in 5.15 (https://lwn.net/Articles/874493/).

Re:Windows is the strangest, or hardest, operating system to... by Bilal_io on Wednesday November 30, 2022 @10:14AM (#33801822)
Thank you for the links. I did a bit of reading to learn a bit and my understanding of the advisory file locking is that it can be ignored by programs that don't respect it. Is it fair to say that the the shell or gui the user used should have respected the advisory lock?

Of course that's assuming the compression program used does attempt to apply file lock, which may not be the case according to another comment.

Re:Windows is the strangest, or hardest, operating system to... by 323 on Wednesday November 30, 2022 @09:51AM (#33801520)
> so the compression program you used

The standard Linux compression programs, zip, gzip, tar, don't lock by default. I don't even think they have such an option.

Re:Windows is the strangest, or hardest, operating system to... by trelane on Wednesday November 30, 2022 @09:52AM (#33801531)
How did you lose data? It looks like it was WAI. You were writing to a file and deleted it. How did you expect that to go down?
Re:Windows is the strangest, or hardest, operating system to... by 323 on Wednesday November 30, 2022 @09:56AM (#33801576)
I was expecting that the process writing to the now deleted file would throw some kind of error/exception that the file doesn't exist anymore. I would have noticed that. But instead it silently continued writing into the void.
Re:Windows is the strangest, or hardest, operating system to... by chasil on Wednesday November 30, 2022 @10:28AM (#33802024)
POSIX does not work this way.

When the last directory entry for a file is passed to the unlink() system call, the file is removed from the directory hierarchy.

However, the data on media will be deleted only after all open file descriptors are closed.

One exploitation of this feature that I have seen is the SQLite temporary tablespace, which is created and immediately unlinked, ensuring that it will not persist after the program terminates.

Re:Windows is the strangest, or hardest, operating system to... by noasaservice on Wednesday November 30, 2022 @10:55AM (#33802521)
> POSIX does not work this way.

Yes, it does. Windows is POSIX/FIPS-151

https://www.quora.com/Is-Windows-POSIX-compliant

Re:Windows is the strangest, or hardest, operating system to... by chasil on Wednesday November 30, 2022 @11:11AM (#33802810)
It was, but the POSIX subsystem was removed.

In any case, I have never seen any way to coerce POSIX unlink() behavior on Windows.

'Broad software compatibility was initially achieved with support for several API "personalities", including Windows API, POSIX, and OS/2 APIs – the latter two were phased out starting with Windows XP.'

https://en.wikipedia.org/wiki/Windows_NT

Re:Windows is the strangest, or hardest, operating system to... by jonhohle on Wednesday November 30, 2022 @10:09AM (#33801760)
As others have mentioned, it was still writing to disk, but its directory entry was removed. This is considered a feature since the data will be automatically cleaned up once the process holding the last file descriptor closes it or terminates. Also as others have mentioned, Linux provides an additional directory entry through /proc, something not available on most other OSs.

In this case, you can have your cake (delete the directory entry) and eat it too (get the data back through /proc).

Re:Windows is the strangest, or hardest, operating system to... by phendrenad2 on Wednesday November 30, 2022 @10:52AM (#33802465)
What if something else writes a file to that location on disk? Can you still have your cake?
Re:Windows is the strangest, or hardest, operating system to... by trelane on Wednesday November 30, 2022 @11:06AM (#33802709)
The "location on disk" (blocks) are owned by the file until all descriptors to it are closed. So nothing else can write to those blocks (actually, inodes) until all file handles to it are closed. At that point, the inodes in the file will be freed to be reclaimed by another file.
Re:Windows is the strangest, or hardest, operating system to... by trelane on Wednesday November 30, 2022 @11:13AM (#33802842)
This is actually really handy behavior to have in a number of cases. A prominent example is temp files. They will automatically be cleaned up on process exit by the filesystem if you open and then delete them. It also helps prevent (not completely, but greatly reduces the window) others from accessing the temp file. you can also use this for intermediate files. Process A creates and writes, B opens for read and immediately deletes the file. A can continue writing and B continue reading until both close their file descriptor, at which point the inodes will get freed.
Re:Windows is the strangest, or hardest, operating system to... by phendrenad2 on Wednesday November 30, 2022 @10:31PM (#33812000)
That doesn't answer my question. I'm saying that you can't recover the file in any realistic way, in a reliable way. Once you close the file descriptor, the file is gone.
Re:Windows is the strangest, or hardest, operating system to... by trelane on Wednesday November 30, 2022 @10:00AM (#33801635)
I still don't understand the loss. The original data that was going into the zip was still there. Or did you the write pipeline delete it at the end of something?

More precisely, what data was lost, and how did it get lost?

Re:Windows is the strangest, or hardest, operating system to... by scbrg on Wednesday November 30, 2022 @10:21AM (#33801930)
There are three processes involved.

Process P, the data producer, writes to file foo.

Process Z, the zip-process, reads file foo and produces foo.zip

Process rm, removes file foo.

I imagine it went a bit like this:

    P --output foo &
    Z < foo > foo.zip
    rm foo
    # time passes
    # process P terminates
Any data written to foo since Z was run is now lost.

User 323 assumed that either rm would fail, letting them know that foo cannot be deleted, or that P would throw an error when the file was deleted.

(I don't think this is a reasonable expectation, and it's a failure on 323's hand of not learning the UNIX file model, but there's the situation).

Re:Windows is the strangest, or hardest, operating system to... by trelane on Wednesday November 30, 2022 @10:35AM (#33802131)
In this case, it would have been deleted anyway.

I think I can see the loss:

1. Start zip. 2. In parallel, copy the intermediate zip file. 3. Delete the zip 4. Delete originals

The data was deleted in step 4 and is the loss. It notably would also had occurred had the zip terminated early or not zipped _all_ the files for some reason. The process was not resilient.

Re:Windows is the strangest, or hardest, operating system to... by 323 on Wednesday November 30, 2022 @10:53AM (#33802478)
I understand the UNIX file model. My mistake was that I thought that the data producer was writing to a different file (think something like log-rotation).

I think it's debatable if it's reasonable to continue allowing writing to an unlinked file.

There was discussion some time ago about Postgres data loss because of something similar, where the linux kernel returned successfully from fsync despite the movable media not being present anymore.

> How is it possible that PostgreSQL used fsync incorrectly for 20 years, and what we'll do about it

https://archive.fosdem.org/2019/schedule/event/postgresql_fs...

Re:Windows is the strangest, or hardest, operating system to... by Tobu on Wednesday November 30, 2022 @09:57AM (#33801600)
I don't see why you'd blame Linux for deleting a file you asked it to. However, if the process is sufficiently long-running, it is possible to relink the file by looking inside `/proc/$(pgrep yourprocess)`.
Re:Windows is the strangest, or hardest, operating system to... by pdntspa on Wednesday November 30, 2022 @10:12AM (#33801789)
Sounds like a pretty good feature to me. Annoying, for sure, but also a safeguard that prevents some weird instability.
Re:Windows is the strangest, or hardest, operating system to... by elzbardico on Wednesday November 30, 2022 @11:13AM (#33802845)
You can open files non-exclusively on windows. If your antivirus doesn't do it, it is not a problem with the operating system but with the application. Frankly, the windows behavior, while annoying in some situations because of badly behaved applications, is much more logical to me and avoids issues like what you described here. People are used to Unix. I know because I am too; the only non-linux or mac os machines I have at home are the windows laptops of my kids. But yet, on this regard, I think that the windows behavior, while annoying because of badly written apps, it the best approach.
Re:Windows is the strangest, or hardest, operating system to... by ethbr0 on Wednesday November 30, 2022 @11:44AM (#33803360)
The problem with Windows is that most applications, including Microsoft's own app-level stuff, are badly behaving.

And Microsoft's been trying to manage that insanity since 1995.

Re:Windows is the strangest, or hardest, operating system to... by herio on Wednesday November 30, 2022 @09:35AM (#33801272)
> Practically, though, it's a shit show.

I usually put it as "Deep inside windows is a really beautiful OS just screaming to be let out from under all that junk on top."

The NT kernel isn't that bad, different from unix for sure but still good. It then just keeps getting progressively worse as you go upwards in the stack from there.

Re:Windows is the strangest, or hardest, operating system to... by P5fRxh5kUvp2th on Wednesday November 30, 2022 @09:36AM (#33801304)
I think that file locking was a decision made with good intentions, but it's probably one of the single biggest mistakes in the windows ecosystem.

And I understand people will argue for it because it does have some utility, but not near enough to pay for the all the damage it's done to people's time.

Re:Windows is the strangest, or hardest, operating system to... by elzbardico on Wednesday November 30, 2022 @09:33AM (#33801241)
First is a design decision. The second can be easily solved by configuring the appropriate exclusions on Windows Defender.
Re:Windows is the strangest, or hardest, operating system to... by scbrg on Wednesday November 30, 2022 @10:31AM (#33802069)
Can I, as an application developer, configure a user's exclusion list in Windows Defender?

If yes - that sounds insane!

If no - it doesn't really help, then, does it? The complaint was that an application developer cannot create a file and then just move/remove it when they please.

I'm neither a Windows user nor Windows dev, so I might be missing something.

Re:Windows is the strangest, or hardest, operating system to... by elzbardico on Wednesday November 30, 2022 @11:19AM (#33802955)
He writes compilers and developers tools. There are plenty of other developers of compilers and developer tools for Windows who apparently don't see this as big hassle because probably they understand that Windows have other ways of doing things differently from the way he is used to doing in Unix.

If his application can only work by creating and deleting files as soon as they are created, then it makes sense for him to point his users to the appropriate documentation.

Re:Windows is the strangest, or hardest, operating system to... by AnIdiotOnTheNet on Wednesday November 30, 2022 @09:32AM (#33801235)
> My "favorite" is the inability to delete a file that is open by another process.

What does the alternative look like?

Lets say a process has a file open. Lets say it is a really big one, like 200GB. Ok, so our disk is nearly out of space, better delete this 200GB file, problem solved right?

Only not. Because now even though the file looks deleted, the process still has it open and that space is still allocated to it.

So either you're hiding reality from the user, or you're preventing them from deleting a file that is in use. Windows went one way and UNIX went another.

Re:Windows is the strangest, or hardest, operating system to... by codedokode on Wednesday November 30, 2022 @09:36AM (#33801300)
Wouldn't a perfect solution be to add a function "queue file deletion after it is closed" to Windows?
Re:Windows is the strangest, or hardest, operating system to... by 323 on Wednesday November 30, 2022 @09:46AM (#33801423)
It already has something similar, you can request for the deletion of a locked file on reboot.
Re:Windows is the strangest, or hardest, operating system to... by codedokode on Wednesday November 30, 2022 @09:47AM (#33801452)
No that's not what I meant. I meant delete at the moment file becomes unused.
Re:Windows is the strangest, or hardest, operating system to... by smileybarry on Wednesday November 30, 2022 @10:22AM (#33801941)
It's supported if the current program allows it. "FILE_SHARE_DELETE" means your delete succeeds but gets processed once their handle closes.
Re:Windows is the strangest, or hardest, operating system to... by codedokode on Wednesday November 30, 2022 @02:14PM (#33806011)
This doesn't make much sense though. Why do we need a program's permission to delete file after it has been closed?
Re:Windows is the strangest, or hardest, operating system to... by smileybarry on Thursday December 01, 2022 @04:20PM (#33822945)
It’s not after it’s been closed, it’s during.

When you open a file on Windows, you can share: read, write and/or “mark to delete”. A lot of times you don’t share any (read can lead to data incoherency; write means you can go out of sync in offsets with someone else; delete might not be relevant if it’s your database file). But if you do, the file isn’t “locked” if someone else opens it for the permissions you’ve agreed to share.

“FILE_SHARE_DELETE” is a little tricky because you can’t delete a file in use, because after all it’s _in use_. So instead, your request to delete puts a mark on it that prevents future opens, and completes the delete once the previously open handles all close.

And except for very specific cases (PE mapping, special “on-purpose” locking, specific APIs) you can always rename/move a file in use, so combined with “FILE_SHARE_DELETE” it’s sort of equivalent except for the space not being freed immediately.

Re:Windows is the strangest, or hardest, operating system to... by wlll on Wednesday November 30, 2022 @10:32AM (#33802086)
"A process is writing to a 200GB file"

There's two problems here, the process and the file, it seems you need to deal with both situations on both styles of OS. You could truncate the file (there's also a `truncate` command I have never used):

cat /dev/null > somefile

and let the process continue writing, or you could just `rm` the file, then either kill the process (or the other way round), or if you've got mysterious disk space usage issues you think are due to still open but deleted files you can:

lsof | grep deleted

I'm an ex (mostly) sysadmin and so this stuff is easy, but is obviously out of reach for "normal" users. Personally as someone who still uses Unix-like machines (Mac, servers) and Windows (games, chkdsk) and I greatly prefer the Linux/Unix way and find the Windows way frustrating.

Re:Windows is the strangest, or hardest, operating system to... by quietbritishjim on Wednesday November 30, 2022 @10:36AM (#33802162)
I've been in exactly this situation on production (with a panicked operator on the other end of the phone and any number of other applications that would've been brought down). On either platform, you end up needing to kill the offending program to release the resource. But at least on Windows you know it! On Linux you can unlink the file, realise the problem still exists, and now you've lost an avenue for figuring out the real problem.
Re:Windows is the strangest, or hardest, operating system to... by pxc on Wednesday November 30, 2022 @11:32AM (#33803191)
> Lets say a process has a file open. Lets say it is a really big one, like 200GB. Ok, so our disk is nearly out of space, better delete this 200GB file, problem solved right?

Not naively intuitive, but for this you can write an empty file to the large open file with shell redirection.

  cat /dev/null > /path/to/big/file
and that will free up the space on disk immediately. Not great, but more or less nicely handles the somewhat common runaway log file case.

I get how this corner case sucks, but to me it seems so much better than the endless parade of reboots and application restarts necessitated by file locking in the Windows world.

Re:Windows is the strangest, or hardest, operating system to... by maldev on Wednesday November 30, 2022 @09:44AM (#33801394)
This is by design though, if another process has a lock on a file, they don't want you to delete it, since it could break another process. They actually do allow it if the applications open it with the createfile flag FILE_SHARE_DELETE. Or you can do it as a transacted operation, which will delete the file "eventually". Again, it's by design, you have to be explicit if you want someone to delete a file you're using, which is honestly a better design than having it be the default with the option of locking the file like Linux does.

If you really want to close it and know you could break another process but don't care(Which you should), you can use NtQueryFileInformation to get the process ID's that have the file opened, then use OpenProcess with the PID, then use NtQueryProcessInformation to get the open handles. Call DuplicateHandle on each of the handles. Then use NtQueryObject on each of them to get the name of the file, then close it.

Re:Windows is the strangest, or hardest, operating system to... by programmer_dude on Wednesday November 30, 2022 @10:45AM (#33802330)
> since it could break another process.

This isn't how things work on Linux. It keeps the file "alive" as long as there is at least one process using it. Any processes which do not have the file open already will not be able to see it but those that do can keep using it. The file will be deleted when all processes release the file.

Re:Windows is the strangest, or hardest, operating system to... by lizknope on Wednesday November 30, 2022 @11:11AM (#33802795)
I remember getting the "text file busy" message on various Unix systems in the 1990's

https://stackoverflow.com/questions/16764946/what-generates-...

Re:Windows is the strangest, or hardest, operating system to... by mort96 on Wednesday November 30, 2022 @11:48AM (#33803436)
That's about modifying files though, not deleting files. If you delete an executable that's currently running and create a new one with the same path, that's fine. If you try to modify an executable that's currently running, the kernel won't let you.
Re:Windows is the strangest, or hardest, operating system to... by yencabulator on Wednesday November 30, 2022 @06:39PM (#33809691)
Not normally on delete. (Most common exception: you're trying to delete an active mountpoint.)

Where most people see that is attempting to mutate a currently running executable. That's forbidden, as it would lead to executing essentially random code. You can replace what file the filename points to, with rename.

Re:Windows is the strangest, or hardest, operating system to... by Brian_K_White on Wednesday November 30, 2022 @12:40PM (#33804382)
"don't want you to delete it, since it could break another process."

There is no such problem. On all the unix-likes, the kernel handles that perfectly naturally.

Think of deleting a file as requesting the file deletion from the kernel rather than directly doing it like in assembly with no os.

When you delete a file, the only thing that happens for sure immediately is no other process can see it in the filesystem, so no new access can be made. To all processes that didn't already have an open file handle, it is effectively deleted and no longer exists.

The contents are not necessarily touched yet, and the filesysyem has not yet necessarily released the occupied inodes and blocks for any other use yet, they are all still tracked as the original file, but now invisible that nothing else except the kernel can see or access.

It stays like that as long as any process anywhere has an open file handle to that file.

Any process with a handle can continue using that handle as normal. If it was opened for write, it can continue to write, seek, read, etc, whatever modes the handle was created with.

The kernel even keeps on coordinating between multiple processes accessing the same now-invisible file. The open file handles aren't just pacifiers, it's still a real file.

But no new file handles can be opened. One by one as processes close file handles, they can no longer open new ones, until the last user has released the last handle.

Only at that point the kernel frees the inodes and blocks in the filesystem making the disk blocks available for new files.

No other processes break, and it's all perfectly graceful and not a problem at all.

For NT not to have that is like some 70's trs-80 stuff.

And holy cow that stuff you just described about querying all other processes...holy cow, not an advertisement for a great, desirable, slick system. "37 easy steps!" It's almost like you were writing a joke to say something is reasonable and then proceed to describe an absolutely laughable process.

Re:Windows is the strangest, or hardest, operating system to... by csmpltn on Wednesday November 30, 2022 @12:49PM (#33804533)
> "But no new file handles can be opened. One by one as processes close file handles, they can no longer open new ones, until the last user has released the last handle."

Or, you know... the computer has to restart itself for some reason before the file was fully deleted, and you get a fragmented disk.

If I'm asking to delete a file, I want the file deleted. I want to know whether the deletion succeeded or not. I don't want it to secretly hide in a purgatory somewhere.

Is this the year of the Linux desktop already?

Re:Windows is the strangest, or hardest, operating system to... by Brian_K_White on Wednesday November 30, 2022 @01:18PM (#33805059)
This is a ridiculous comment.

If the kernel gets to shut doen gracefully, then there is no problem at all. The file handles are closed when the processed are killed and the filesystem is unmounted in a consistent state.

If the kernel does not get to shut down gracefully (crash or power loss) the filesystem is left no more or less inconsistent than any other time, and is cleaned up by fsck or by the journal if there is one. Either way the file is finished being deleted on reboot because no processes have open handles and the kenel and the fs know that those blocks are deleted. The last on-disk state of those inodes was that the blocks are not used by any normal file. The kernel knows not to continue holding them for no reason.

There is no such problem.

Re:Windows is the strangest, or hardest, operating system to... by maldev on Wednesday November 30, 2022 @01:14PM (#33804995)
If you read my comment, you can see in the first few words I mention how you can do a delete transaction and it will delete it when it's not being used anymore. Or you can also just open the file with the share delete flag and it will allow the same. And linux doesn't handle it perfectly, you see errors like "text file busy". I don't get why you chose to argue how the non recommended, brute force method, is lengthy. It's not intended to be used and was mainly just to show you can, and there's nothing stopping you.

Why is explicitness bad? Would you rather have those weird errors on linux where it's open by default? Or have it where the program author has to say "Yes, this file is fine to be deleted while i'm using it".

Re:Windows is the strangest, or hardest, operating system to... by Phemist on Wednesday November 30, 2022 @06:09PM (#33809340)
I'm just going by the comments of others but:

"Yes, this file is fine to be deleted while i'm using it"

is fine if all processes play nice, which apparently Windows Defender _does not_. Edit: likely Windows Defender couldn't work if it did? So, in order to consistently delete a file without triggering the file lock, you need to use the work-around.

I'm just guessing here, but wouldn't Windows Defender need to be some privileged process (as it's e.g. an anti-virus) where then this file-locked file deletion process would be impossible to perform? Otherwise, a computer virus could just keep killing the Windows Defender file handler, making it impossible to read its files and keeping Windows Defender from performing its duty.

Re:Windows is the strangest, or hardest, operating system to... by maldev on Thursday December 01, 2022 @12:46PM (#33819713)
Exactly, the developers of Defender decided it needed to lock the file, arguably for alot of reasons. To prevent tampering etc, it's an antivirus, it doesn't want you to be able to bypass a scan of a file, or change it. Windows has things like Datastreams(Which come from Mac), so the same "file", can actually have two different files in it, and require different file openings. IE, "Foo.exe" and "Foo.exe:MALWARE" would be completely different file contents, despite both being foo.exe. And OpenFile("Foo.exe"), would not open foo.exe:MALWARE.

Alot of the confusion comes from people not understanding the functionality. Delete file means "Delete it now" on windows(ignoring slack space). But on linux it means "Queue up the file to be deleted". Windows also has this, but it's going to be a transacted operation, which is literally called DeleteFileTransacted vs DeleteFile, so the Kernel sees noone is using it and then will delete it.

And honestly, if you go up to any lay person and ask them "What does 'DeleteFile'" do. They'll probably respond it deletes the file. Not queues it up for deleted, but other people can still access it. So I think the windows verbage makes more sense, with another function appending Transacted to it, which signifies it will be done eventually.

Re:Windows is the strangest, or hardest, operating system to... by Brian_K_White on Friday December 02, 2022 @07:51AM (#33829826)
There is nothing about antivirus that requires file deletion block on other processes including the antivirus. For one thing, you just said Windows has a similar functionality available anyway just invoked a different way. Is that a way around Defender? It better not be. If it exists as something you can use, and yet still isn't a way around Defender, then it's silly to even be talking about Defender to justify this 70's behavior.

The understanding of laypeople in how a multitasking operating system kernel coodinates a graceful teardown of a shared resource, or fails to in the case of Windows, has exactly no bearing on anything. Why isn't it exactly as reasonable to presume that "any lay person" would expect that they can simply issue a delete command and it happens, without having sit there and wonder why they're stuck and go worry about other processes that they didn't write and don't have any knowledge or control over? It is exactly as reasonable. And both are pure meaningless presumption, and don't matter anyway since the understanding of a lay person would be a ridiculous way to design the inner workings of ... anything, definitely including an operating system.

These arguments are swiss cheese.

Re:Windows is the strangest, or hardest, operating system to... by smileybarry on Wednesday November 30, 2022 @10:17AM (#33801866)
> Combine this with Windows Defender that scans every file that your application creates, and now you have no reliable way of deleting or moving your files.

This doesn't happen for years now due to "opportunistic locks" -- when you open a file being used by an app which support oplocks (i.e.: usually antiviruses), they get a blocking notification and can release the file. They can hold the notification (and stall the requesting application) until they're done, close their handle, and the other app's open succeeds.

Re:Windows is the strangest, or hardest, operating system to... by xwolfi on Wednesday November 30, 2022 @10:24AM (#33801972)
Sweet child, he reads the documentations but doesnt use it. I concur with op, to this day, deleting a fucking file in Windows is an unbelievable chore compared to all their competitors. I tried today, nope, couldn't.

But you dont care, obv you dont use it.

Re:Windows is the strangest, or hardest, operating system to... by kevin_thibedeau on Wednesday November 30, 2022 @10:46AM (#33802339)
Use Shift-Del to bypass the performance shitshow that is the recycle bin.
Re:Windows is the strangest, or hardest, operating system to... by smileybarry on Thursday December 01, 2022 @04:13PM (#33822840)
I use Windows Defender on several PCs, and have used for years. All are kept up to date on Windows 11 (and prior, Windows 10) and not “modded” to disable telemetry etc.

I haven’t had a “locked by Defender” error in at least 5 years, and I would say more if I could remember the last time I did.

I’m also developing a(n existing) product that actually uses oplocks, so I’m speaking from experience here.

Re:Windows is the strangest, or hardest, operating system to... by cma on Wednesday November 30, 2022 @10:24AM (#33801979)
Is this where all the stalls during big compiles come from?
Re:Windows is the strangest, or hardest, operating system to... by indrora on Wednesday November 30, 2022 @06:50PM (#33809836)
That's probably your disks cache catching up with what you've done.

NTFS likes making sure that disks flush their caches regularly, and congestion caused by cache bloating makes it harder. Getting an nvme (or better, while you can, Optane) SSD for compilation on is a good start for improving your build times.

Re:Windows is the strangest, or hardest, operating system to... by dboreham on Wednesday November 30, 2022 @10:34AM (#33802125)
> inability to delete a file that is open by another process

otoh if you have never encountered Unix, you might be surprised that it's even possible to delete a file currently open by another process.

Re:Windows is the strangest, or hardest, operating system to... by BenjiWiebe on Wednesday November 30, 2022 @02:20PM (#33806112)
And if someone is more familiar with nix then windows, trying to delete a directory in Windows can be a teeth-grinding frustration. I don't care* if this file 3 levels down is still open by some background process... If I cared, I wouldn't be trying to delete it!
Re:Windows is the strangest, or hardest, operating system to... by cshokie on Wednesday November 30, 2022 @10:36AM (#33802163)
Windows has the concept of OpLocks on files, which open the file but can be broken by other access. When used properly that should prevent antivirus from ever preventing file deletion. The deletion would break the lock that antivirus has open.
Re:Windows is the strangest, or hardest, operating system to... by mike_hearn on Wednesday November 30, 2022 @10:57AM (#33802557)
But apps have to use it. An example of an app that apparently doesn't is Explorer. Another example: cmd.com. So if you have a shell or explorer window opened in a directory, and an app tries to delete or move it, that app will die. It might be better for Explorer to notice and go up to the next nearest available directory.
Re:Windows is the strangest, or hardest, operating system to... by jaywalk on Wednesday November 30, 2022 @01:12PM (#33804948)
> It might be better for Explorer to notice and go up to the next nearest available directory.

But... that's what it does?

Re:Windows is the strangest, or hardest, operating system to... by mike_hearn on Thursday December 01, 2022 @07:04AM (#33815176)
At least last year I was seeing problems where having Explorer open in a directory would block an app from moving or deleting that directory. So if it was using oplocks then, it didn't seem to be working.
Re:Windows is the strangest, or hardest, operating system to... by phendrenad2 on Wednesday November 30, 2022 @10:54AM (#33802509)
> Practically, though

> someone who works on a C/C++ build toolchain

Pick one. No seriously, tradeoffs have to be made, and I don't think "people who work on build automation" are the intended main use case for Windows Home Edition.

Re:Windows is the strangest, or hardest, operating system to... by yamtaddle on Wednesday November 30, 2022 @02:29PM (#33806245)
I recently discovered that Linux handles processes holding files open a little differently from FreeBSD, too, when I tried to unmount a ZFS volume. Something had ahold of a file on it, so I couldn't unmount it—on FreeBSD you can just say "I want all programs that are preventing this to fuck off and, if they're so inclined, to crash"—and ZFS provides a flag to do just that—and go on with your day, but Linux evidently won't let you (I ended up on some ZFS mailing list archive to confirm this was the case and I wasn't just holding it wrong). You have to go track the process(es) down and kill it(/them) yourself, not unlike how you can't delete a file that's in use on Windows and have to go kill the processes. It was faster to just reboot the damn machine than to do that (a very Windows solution).

[EDIT] It may have been a ZFS export operation, not exactly an unmount? I can't recall for sure. Point is, Linux made you go find and kill the relevant processes yourself, while FreeBSD made it trivial to override that and do what you needed to do with no further fuss.

Re:Windows is the strangest, or hardest, operating system to... by yencabulator on Wednesday November 30, 2022 @06:49PM (#33809820)
Back in the day there was a patch floating around that let you mark mounts as "bad", and all open files would be shunted to a "badfs" which gave I/O errors for all operations.

Most of the discussion around it has linkrotted. https://lwn.net/Articles/192632/ has some mentions.

Some filesystems implement a less-comprehensive variant that's `umount(2)` with `MNT_FORCE` -- but generally that's only network/FUSE-style ones:

       MNT_FORCE (since Linux 2.1.116)
              Ask  the filesystem to abort pending requests before attempting the
              unmount.  This may allow the unmount to  complete  without  waiting
              for  an  inaccessible server, but could cause data loss.  If, after
              aborting requests, some processes still have active  references  to
              the  filesystem,  the  unmount  will still fail.  As at Linux 4.12,
              MNT_FORCE is supported only on the following filesystems: 9p (since
              Linux  2.6.16),  ceph  (since  Linux  2.6.34),  cifs  (since  Linux
              2.6.12), fuse (since Linux 2.6.16), lustre (since Linux 3.11),  and
              NFS (since Linux 2.1.116).
Re:Windows is the strangest, or hardest, operating system to... by ThinkBeat on Wednesday November 30, 2022 @09:08AM (#33800938)
NT upto 4 was beautiful when it was released in my opinion. It was a "serious" "workstation" operating system. Supporting multiple platforms.

The ability to run different "operating systems" was neat. The graphics stack was all in user space.

The biggest hope was a selling WindowsNT with Alpha CPUs to the Defense department if memory serves. (Which is why the POSIX parts were added) That never happened.

NT4 was not made to be the best OS for games.

After that Microsoft has cut a lot of neat parts out and bastardized the clean separation between the kernels and user space in order to make the OS faster.

I wish they had branched it "Windows Home" and "Windows Workstation"

It would be a lot of work I guess. They do have Windows Service but I think that it has undergone the same changes.

Re:Windows is the strangest, or hardest, operating system to... by jstarks on Wednesday November 30, 2022 @09:17AM (#33801049)
NT4 already had the graphics stack in kernel mode.
Re:Windows is the strangest, or hardest, operating system to... by indrora on Wednesday November 30, 2022 @06:54PM (#33809886)
They tried that.

It was called Windows Me.

Also, the selling point of the Professional editions was and continues to be use in Active Directory and business environments, not developer workstations.

Re:Windows is the strangest, or hardest, operating system to... by adzm on Wednesday November 30, 2022 @09:43AM (#33801372)
IO completion ports (IOCP) was such a brilliant design, and still holds up today. It's fascinating how long it took for similar paradigms to become more dominant elsewhere eg with kqueue
Re:Windows is the strangest, or hardest, operating system to... by dboreham on Wednesday November 30, 2022 @10:37AM (#33802176)
See another recent thread for my theory (based on what I heard from various Unix vendors at the time) that this was mostly due to fear of MS patent litigation. iirc AIX did have an IOCP-like feature. MS acquired the rights to DEC's patents in this space, handy since IOCP is similar to VMS's QIO.