3 ms·
How is APT able to update the code of a running process?
by chrisseaton 4y ago
How is APT able to update the code of a running process?
- bogwog 4y agoI'm not sure of the details, but when you update a running Firefox all your currently-open tabs continue to work, but when you try to open a new one you'll get an error message telling you that you need to restart Firefox to keep using it.
- chrisseaton 4y agoAh right I thought you meant it did some kind of hot-patching - sounds like it still needs a hard restart like normal.
- mort96 4y agoIt unlinks the old file paths and creates new ones in their place. Files in Linux are reference counted, and they're only actually marked as deleted on disk once the reference count goes to 0; a directory entry is one reference, but the running process is also a reference, so even though the path /usr/bin/firefox has been replaced with a new file, the old file is still in use by the existing Firefox process. When you stop Firefox, the refcount for the old file will drop to 0, and when you start it again, the new /usr/bin/firefox will be launched. The same idea applies to all libraries, where the old version of say /usr/lib/firefox/libxul.so can still be referenced by the running firefox process even after apt has replaced it with a new version. It's not a great system honestly, Firefox will launch new processes sometimes and the IPC system kinda breaks down when the parent process and the child process are from different Firefox versions.