I had assumed, without much thought, that linux.ld.so read the lib into VM
when the first process referenced it and then additional processes shared
the address space. Under that assumption, overwriting the disk file with the
same data doesn't hang user processes.
Now I know ld.so mmap's the lib and that tar and cp begin with a truncate.
Does the truncate cause all the lib's pages in VM to get
removed/invalidated...
I guess yes because if it was a file, all the disk blocks would go back on
the free list. Your idea of replicating the privately mapped pages enables
the kernel to emulate my careless assumption.
But what's the best semantics for this, copy into memory or mmap?
Another question, my POSIX.1b book says SHARED and PRIVATE are mutually
exclusive, true for one process but what about several processes, do they have
to use the same mode? It seems that users of a lib would like to see PRIVATE
(maybe to allow horrors like self modifying lib code???), but overwriting
files implies a SHARED kind of operation.
There's more to think about here than I expected.
jeff
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.6.2
mQBtAzC058EAAAEDALjanMr+BdlYckaBjfF1yFGBNBjd/tQzmV8897HWLbqfa6Tt
+M2ed4TnVwsa4JptFozJfIIlnLTO0ZcT1Fhq5Ba5oh/JAidkf2Rfu5uLAw3Smt1Y
GvZTMK8ZHGa6uYB5EQAFEbQGd2ExaGNv
=lEWl
-----END PGP PUBLIC KEY BLOCK-----