r/AskComputerScience • u/DrunkenLupus • Dec 22 '19
When an annoying software asks you to “please restart your computer to finish uninstalling” are they just bullshitting or is it a necessary step for them to reboot and permanently remove the software?
41
u/electrogravity Dec 22 '19 edited Dec 23 '19
I believe this is due to how shared DLLs work/worked on Windows: If you install DLLs and multiple applications are actively using them, you couldn’t simply delete them immediately without killing important active applications. Marking them for deletion and rebooting ensures that those applications get shut down so the DLLs can be removed “safely”.
However, this is actually a silly limitation, because there are many ways to uninstall shared libraries (with some limitations) without requiring a reboot, which is accomplished by other OS’s and applications. This is therefore mostly just a limitation of Windows and the installers of some apps that choose not to use methods that avoid this problem.
In fact, on Linux, you can even remove arbitrary files from your directory while they are in use! The OS doesn’t require you to shut down the applications using the file, it simply is smart enough to “simulate” file deletion (by removing it from the file directory, even though technically the original file is still there while still in use), and automatically “actually” delete the file once all applications are finished with it. The end result from your perspective is that file deletion is seamless, and no reboots or killing of apps are necessary.
I’m no expert here, but I believe modern Windows has ways to avoid this problem. At the very least though, applications can choose to be self contained so that when uninstalling them, shutting them down alone is sufficient to allow full removal of all the DLL dependencies that were installed along with them.
So in other words, need to reboot is a remnant of old/bad OS designs and application architectures. Modern applications generally should not be installing globally shared code (which, in addition to this reason, is also dangerous for security and stability), so shouldn’t have this problem.
But, Windows being Windows means that backward compatibility is guaranteed all the way back to 1776. So even modern applications could in theory use older/bad methods that would require reboots after uninstall.
14
u/Filmore Dec 22 '19
In fact, on Linux, you can even delete files from your hard drive while they are in use!
This is not quite right. The file is still very much there, and any running process which still holds a file descriptor will keep the disk space from freeing up. So the same limitation holds. The major difference is you can actually peek at the processes holding file descriptors and selectively kill them. A system reboot will work as an alternative. So it isn't like linux is "better" from a rote limitation view point, it just has a better tool suite and visibility.
8
u/bokonator Dec 22 '19
So Linux is still better, just not for the reason OP thought.
3
1
u/electrogravity Dec 23 '19
I think my description he quoted was misleading when I said “delete files from your hard drive”, when what I should have said was “remove files from the directory”. I explained in the following sentences that the files don’t get “magically deleted“ until they’re no longer used, but didn’t elaborate much beyond that because then we’d have to get into what it means to “actually delete” a file (free up the disk regions it used to occupy for recycled use) and all its subtleties (assuming minimal fragmentation etc.) That said, I’ll try to make that sentence more accurate.
1
u/bokonator Dec 23 '19
I'm just stating that Windows could have implemented the "delete file while in use" feature and decided not to. Therefor the Linux way probably being better way to do it?
1
u/electrogravity Dec 23 '19
I understand this, but I think my description of this as “simulated deletion” is still an accurate summary of what is happening here. If you don’t care to free up space immediately (which will be true in many cases), you can just forget about it and let the system do it’s thing, right? The ability to selectively manage processes using the old libraries is a nice bonus on top.
4
u/elperroborrachotoo Dec 22 '19 edited Dec 23 '19
this is actually a silly limitation, because when in use, the DLL lives in RAM, not the hard drive
This is not true.
Address space is reserved for the entire DLL in the process that is using it, but (almost) nothing is loaded to physical memory until needed. It can even get kicked out again when physical memory is low. So the file still needs to be there, if more sections from the DLL are required.
Unix-style OS'es do the same, they just don't physically delete the file as long as it is still loaded. When you "delete a file that is in use", it still remains on disk until it's closed.
So it's actually a limitation of the file system, Windows doesn't do that because it "grew up" on a file system that didn't suppport hard links.
(NTFS does support them, since Windows 2000, but doesn't use them that way)
1
u/electrogravity Dec 23 '19
Yeah, perhaps I should have been more precise. I was trying to make a simplified description without getting into virtualized memory, etc. I could probably have been more accurate and simplified it even further though by just saying that there are many ways to effectively allow files to be “deleted” while “in use”.
-3
u/Triplobasic Dec 22 '19
Can you remove your car's old tyres while driving?
5
u/electrogravity Dec 22 '19 edited Dec 22 '19
To continue this analogy: Why do I have to remove my car’s old tires and strip down the entire car piece by piece, when all I’m trying to dump it? Can’t I just dump the whole thing as one self-contained unit?
Also, why are other cars sharing my tires? (JK, this is where the analogy breaks down).
(The answer of course is because Windows doesn’t know how to delete a globally shared DLL when other apps could potentially be using it, and only knows how to solve this by rebooting. Other OS’s are smarter, and can handle this just fine with no reboot.)
3
u/HenryJonesJunior Dec 22 '19
It's a different compromise, not necessarily better.
On those other operating systems, it's entirely possible for you to be running a program which uses version A of a library, replace the library with version B, then start a new program (now running B) which has issues talking to the first program. These issues can be incredibly difficult to debug if you don't know what you're doing.
Whether that's better or worse than rebooting is subjective, but for the average home user, rebooting is simpler to understand.
0
0
Dec 22 '19
[deleted]
1
u/DrunkenLupus Dec 22 '19
But non-Microsoft antiviruses do this all the time. They definitely have an incentive, squeeze as much doubt out of the user as possible before they uninstall, they just might change their mind.
3
u/neozuki Dec 22 '19
An anti virus usually installs drivers / roots itself more deeply than a normal program to do its dirty work. At least they have a decent reason to require a restart compared to more mundane programs.
1
9
u/gedankenlos Dec 22 '19
It has to do with shared libraries on the computer. Under Windows, you cannot delete files that are still being accessed by any program - they hold a lock on open files. When you are shutting down Windows, all running programs will be closed and thus all locks on shared library files will be released. So in theory, when you never reboot your system would be cluttered with unneeded dll files in your Windows folder. In practice you would never notice.
Other operating systems like Linux can in fact mark files as deleted while they are open in some program. The file will not show up in your directory tree anymore and the actual data on your disk will be pruned/overwritten after all programs with a handle on the former file will have closed.