Remote upgrade possible?

Danny MacMillan flowers at users.sourceforge.net
Fri Jan 7 09:34:16 PST 2005


On Fri, Jan 07, 2005 at 07:25:02AM -0500, Mike Jeays wrote:
> On Thu, 2005-01-06 at 23:26, Tabor Kelly wrote:
> > 
> > I routinely use 'portupgrade -rRN' in xterm, in X-Windows to
> > install new ports on my box. The second to last time I did this,
> > one of the ports what was upgraded was xterm. And it worked! Can
> > anybody explain to my why nothing bad happened? Am I running a
> > risk when I do this?
> 
> This seems pretty safe to me. When xterm gets invoked, the whole of the
> code gets loaded into memory for execution, and there is no reason why
> it would look at the disk copy again.  If you upgrade the xterm binary,

I haven't looked at the code, but your assertion is extremely unlikely.
I really want to say "impossible" but as I said, I haven't looked at
the code.  If FreeBSD loaded entire executable images into RAM when
starting new processes, it would perform very poorly.  What is more
likely is that the kernel keeps the image file open during program
execution.  When the xterm binary is replaced, the old binary is still
on disk in its old location, it just doesn't have any directory
entries pointing to it.  Since the kernel still has the file open it
won't be overwritten.  Hence the kernel can and will still load
pages from the old image.  This is a function of the same behaviour
that causes df and du output to differ in some cases.

The lsof(8) utility seems to bear this out, as each process seems to
keep each image (program and shared object files) open during
execution.

A new instance of xterm would use the new, upgraded binary.

-- 
Danny


More information about the freebsd-questions mailing list