22

The Software Updater update-manager pops up and shows security updates for Firefox, for example. Naturally, I will click on "Install Now" to continue.

However, what happens if I still have Firefox running when I do this? Will it still update Firefox? Will the update be skipped and just pop up next time, again? Will the update force Firefox to close and maybe crash? Will it only partially update the software and possibly break my Firefox installation?

  • 10
    Nothing happens, Firefox is open in Ram. Sometimes it detects the update and tells you to restart the browser. But maybe someone with more insight and references can give a better answer. – pLumo May 4 at 12:25
  • 3
    I don't know specifically about Ubuntu, but on Arch (and I don't think it's all that different in this case), updating firefox under its feet while running seems to work, but then the first thing you do in firefox crashes the thing. I've always just attributed that to the complex nature of modern-day browsers, runtime-loading all kinds of stuff. But firefox is the only thing that happens with for me. – tomsmeding May 4 at 20:03
  • 2
    Firefox will stop the next time you open a tab, and tell you that it needs to restart. Other apps may do something different. – Michael Hampton May 5 at 4:22
40

You must be thinking of Windows. Unix did it right, and then later, Windows came along and developed wrong ways of doing things.

With Windows, replacing a file that is in use by a running process can badly affect that process. The process will reference locations within that file and get incorrect information from it, usually with catastrophic results. That's why a Windows update generally requires a reboot to ensure that all processes are using correct versions of libraries etc.

With Unix, once a file has been opened by a process, that same file will always be available to the process even if the original file is removed from the filesystem.

After an update, the filesystem will contain a different version of the file, and all process that start after the update will use that new file. But, unlike Windows, all old Unix processes will continue using the original files that they started with. Even though no longer accessible via the filesystem, those files will persist as long as any process is using them. Eventually, when no processes are using the files, the old version of the files will finally be deleted.

You may of course decide to restart Firefox (or other processes) if you want to get the benefits of the update right away. The choice is yours.

18

Typically, updating a program while it's already open is no problem – as the other answerers have explained, a running process can continue to run even if its executable is deleted.

However, due to Firefox's multi-process model, you may get a prompt to restart it after an update anyway. This is because Firefox spawns new processes to isolate different websites, so if it spawns a new process after you've updated it but before you restart Firefox, the new process will be a newer version of Firefox than the rest of the browser. This can cause various issues, so Firefox might prompt you to restart it before allowing you to continue.

Incidentally, Chrome avoids this by using a "zygote" process that sits around doing nothing; when the browser needs to spawn a new process, instead of asking the OS to execute the browser executable again (which would execute the possibly-updated binary) it asks the zygote process to duplicate itself, and one of the copies then becomes a normal renderer process.

  • 1
    Also, with a complex application like Firefox, everything it could possibly need to deal with anything it encounters isn't loaded into memory when the program launches. So components that get loaded as needed may similarly create a mismatch of versions. I've often had Firefox hang when updating it while it was running. – fixer1234 May 5 at 0:33
  • It's not just browsers with multi-process models, but any situation where libraries are used for IPC and the libraries can be loaded before and after the update - although browsers are probably the most well known example of this these days (COM interop on Windows being pretty prevalent means many more programs can implicitly do something like this though). I also can't imagine that Chrome completely avoids this problem with the zygote process - does it really load every single library that it might need at any point at startup? – Voo May 6 at 14:08
  • @Voo asks "does it really load every single library that it might need at any point at startup?". I don't know about this specific example, but in general it isn't necessary. All that is required is to ensure that each possible library is opened at startup, thereby guaranteeing that the correct data will be read should it ever be needed. Opening a file (or dozens of files) is a trivial expense compared with loading everything they contain. – Ray Butterworth May 7 at 1:03
  • @Ray Fun fact: dlopen only takes a file name but not file descriptors so that might not be as simple as you thought it would be (you can play around with /proc but that's notoriously different along the *nixes). But the bigger issue is that that would eliminate most use cases where dynamic loading is used to begin with. – Voo May 7 at 6:46
  • @Voo, sorry, I mistakenly thought this comment was in the unix-oriented thread, not about Windows and dlls. – Ray Butterworth May 7 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.