Niels Hald Pedersen wrote:

> > The program code and read-only data (e.g. string literals) are even
> > more `virtual'; they are paged into memory from the executable as
> > required, so they never occupy any swap.
> 
> Is this true ?

Yes.

> On my system, it is possible to compile/link a new (changed) version of
> a program, while a copy is still running.

Yep.

> After the link, the running old copy no more have a valid
> executable, thus. How come ?

If you try to write to a file which is in use as an executable, you
will get ETXTBSY (Text file busy). In this case, the linker will write
to a temporary file, then replace the existing file with the new
version.

It is safe to delete (more precisely, unlink) a running executable. 
Unlinking a file only removes the directory entry. The file itself
(the inode and the data) is only removed when there are zero (hard)
links to it and no process has it open. So any processes which are
running the old executable will continue to have access to it.

-- 
Glynn Clements <[EMAIL PROTECTED]>

Reply via email to