Home » Questions » Computers [ Ask a new question ]

In linux, what would happen to a running program when it's executable file has been modified or deleted?

In linux, what would happen to a running program when it's executable file has been modified or deleted?

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.

Asked by: Guest | Views: 73
Total answers/comments: 2
Guest [Entry]

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.
Guest [Entry]

"What will happen to those running ruby
processes?

make a copy of /usr/local/bin/ruby
[if it's not running, run /usr/local/bin/ruby ]
try: rm /usr/local/bin/ruby
and see for yourself :)"