On Tue, May 13, 2014 at 8:44 PM, Rustom Mody <rustompm...@gmail.com> wrote: > On Tuesday, May 13, 2014 3:30:36 PM UTC+5:30, Chris Angelico wrote: >> Actually, even the file system can do some of this to you. I was >> checking lsof on one of my Linux systems a little while ago, and found >> that I had half a dozen old versions of a program, all with the same >> file name, all deleted. (When you unlink a running binary on Linux, >> the program keeps running the old version, and then you can put a new >> version in its place, with the same file name. Any new invocation will >> pick up the new binary; existing ones keep what they have.) So a >> program can unlink itself, write out a new version of itself, and >> happily keep going - letting new invocations take the changed version, >> safely. Again, not exactly self-modifying code... or is it? Again, >> tamed by boundaries. > > Your lsof example looks like a rather typical case of ugly self-modifying code > Self-modifying code has many flavours; consider: > > $ sudo apt-get upgrade apt-get > > relatively harmless but self-modifying nonetheless >
Heh. Those are going to be exactly the same. (In actual fact, it was a "sudo make install" that created the situation I described.) The only difference is that you probably don't have any other instances of apt-get running, meaning the change takes place for the next run - but while that's running, you would see the old /usr/bin/apt-get as a deleted and open file. ChrisA -- https://mail.python.org/mailman/listinfo/python-list