25

screenshot

How does apt-get remove xterm go through? And after it's been uninstalled, xterm doesn't close and continues to function normally.

Is the xterm process cached in RAM whilst it is running?

Volker Siegel
  • 13,295
Huey
  • 799

3 Answers3

53

Not quite. The file is already open by the program. Deleting the file ( and then replacing it with another version ) does not affect the running program because the original file is held open ( though without a name on disk to open it again ) until the program is done with it. Only when all handles to the file are closed are its data blocks on disk released. Until then the open file can be read and written just like normal -- the only change is that nobody else can open it since its name has been removed.

While parts of the program may have already been read into ram when it is deleted, they may still be discarded and re-read later, or new parts of the program that had not previously been executed can still be loaded from the deleted file.

psusi
  • 38,031
8

Is the xterm process cached in RAM whilst it is running?

Exactly. It's similar to the process that allows you to install updates to things while they're running without them crashing. And also why you have to restart services after you update them. Once something is running, its binary is in memory.

If it depends on other files (that aren't in a held "open" state) that are removed or replaced, that might cause issues but for something as discrete as xterm, that isn't an issue.

Oli
  • 299,380
2

It is in fact a feature of how computers work: When a program is invoked it is indeed loaded into the memory and it works from there.

A file actually works in the same way. To avoid problems many files in UNIX-ish systems create locks.

The actual riddle is why you can't do such and similar things in Windows.

This feature is actually what allows you to update the whole system, including the programs that are active in your system. ;)

runlevel0
  • 372