You are not logged in.

#1 2012-08-05 15:37:53

reed1
Member
Registered: 2011-01-14
Posts: 24

How Pacman Replace (Upgrade) Running Executable ?

I always wonder how pacman (or linux package system in general) resolve this issue. In windows, the program has to be restarted or whatsoever. In arch howerver, I once had zsh (shell) v4 running on a terminal, then I upgraded zsh to v5 in another terminal, after that, at the first terminal, I tried zsh --version and it says 5, lol, how could this happen ? is zsh spawning a new process ? if that's the case how can the old zsh still able to run and process command ? is it loaded fully into memory before so the file in hdd can safely be replaced ? then how about a package that has several /lib dependency, if the /lib is upgraded, can the program continue to run ? And how about a program that's heavily being used, let say mysql, and then updated while running, is that possible ? Is pacman storing the upgraded files somewhere then inject those when program is not being used ? or inject it when the computer starts / shutdown (like windows update) via initscrips or something, is there any standard on resolving this issue across many package manager available for linux ?

I'm puzzed with this. Sorry if my explanation isn't clear big_smile
Thank you,

-reed1

Offline

#2 2012-08-05 16:04:33

kokoko3k
Member
Registered: 2008-11-14
Posts: 1,485

Re: How Pacman Replace (Upgrade) Running Executable ?

It is a matter of operating system, not of distribution.
On linux every file that is open from an application will be accessible to it, even if deleted from disk.
On windows it will be locked and you can't do much on that file until the application has released it.

Offline

#3 2012-08-05 18:53:43

mhertz
Member
From: Denmark
Registered: 2010-06-19
Posts: 664

Re: How Pacman Replace (Upgrade) Running Executable ?

Yes, when writing zsh --version, then you're spawning a new /bin/zsh process.

The upgrades relates to files on disk and not what's currently loaded into memory, and hence, sometimes problems can occure on big updates where e.g. dynamic libs change name/locations...

Offline

#4 2012-08-06 11:56:06

yaffare
Member
Registered: 2011-12-29
Posts: 71

Re: How Pacman Replace (Upgrade) Running Executable ?

When you open a file, the kernel follows the link, and assigns the inode a file descriptor (a number that it keeps track of internally). When you delete the file, you are "unlinking" the inode; the file descriptor still points to it. You can create a new file with the exact same name as the old file after deleting it, effectively "replacing" it, but it will point to a different inode. Any programs that still have the old file open can still access the old file via the file descriptor, but you have effectively upgraded the program in place. As soon as the program terminates (or closes the file), and starts up (or tries to access it again), it accesses the new file, and there you have it, a completely in-place replacement of a file!

(stolen from Why linux can be updated without rebooting)


systemd is like pacman. enjoys eating up stuff.

Offline

#5 2012-08-17 07:41:12

reed1
Member
Registered: 2011-01-14
Posts: 24

Re: How Pacman Replace (Upgrade) Running Executable ?

That's it !, thx very much @all smile

Offline

Board footer

Powered by FluxBB