On Tue, 6 Jul 1999, Zhihui Zhang wrote: > > For a big executable file that is being run by the OS, all its contents > may not be loaded into the memory. At the same time, the developer gets > impatient and wants to create a new version of the same file. He could > modify the makefile to output the new version to a different file name, > but this is tedious. This new version should not overwrite the older > verion of the file being run. My question is how FreeBSD prevents this > from happening? Can anyone point out for me where in the source code this > is handled?
He should unlink the file before "overwriting it". The running executable will still remain tied to the old data as the reference count will stay positive until all open descriptors pointing to it are close()'d. You can test this by writing a program that opens a file, scribbles some data to it, keeps the file open, meanwhile something else comes along and deletes that file, the first program will still see the old contents, even if a new program writes out a file with the same name but different contents. -Alfred To Unsubscribe: send mail to majord...@freebsd.org with "unsubscribe freebsd-hackers" in the body of the message