Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let's say /usr/local/bin/ruby is running in the background, and then we overwrite ruby with a different version, or even delete ruby.

What will happen to those running ruby processes?

share|improve this question
up vote 3 down vote accepted

It depends on exactly how the executable is updated. If the same file is opened and parts of it are changed, bad things will happen. If it is removed, the file is removed from the directory structure of the filesystem, but not actually unlinked (i.e., deleted) until the last process that has it open has executed it exits. So if the executable is removed and a new one with the same name written in its place, the old one should continue to work ok.

share|improve this answer

They'll keep on going. Maybe crash horribly if they try and access themselves and receive something utterly wrong. I wouldn't do it unless I had to :)

share|improve this answer
Yep. I manually update software all the time while scripts are running. – John T Jan 11 '10 at 18:18

What will happen to those running ruby processes?

  1. make a copy of /usr/local/bin/ruby
  2. [if it's not running, run /usr/local/bin/ruby ]
  3. try: rm /usr/local/bin/ruby
  4. and see for yourself :)
share|improve this answer

It is my understanding that the Linux kernel has a component called the loader that opens the executable file itself, containing the image, during the loading/linking process, and once done with linking to libraries, etc., the loader closes the file. Thus, this process happens and is complete by the time the kernel actually launches the process.

I'm not sure if the original executable on disk needs to be referenced if the executable later tries to import external libraries.

I would say, and it's been my experience that, if you delete the executable on disk, the executable loaded in memory isn't affected. Likewise, if the executable file is replaced with a newer versions, currently executing ones aren't "automatically" updated unless they are halted and relaunched.

I had issues with a RAID controller that caused the entire disk that the root directory and other partitions was mounted on to suddenly act as though it was disconnected. Couldn't load new programs, but ones in memory were working fine, until they needed files from the disk.

share|improve this answer
That doesn't sound very efficient. I think Windows would memory-map it instead, so pages are loaded on demand. – sashoalm May 9 '14 at 14:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .