hookenz
hookenz

Reputation: 38997

Changing the filename of a memory mapped file

Is it possible to change the name of an already open memory mapped file, or, do I need to close it, rename it and then mmap it again?

Upvotes: 2

Views: 1992

Answers (1)

caf
caf

Reputation: 239371

Renaming a file while it is open is fine, regardless of whether it is mmaped or not.

In UNIX-like systems, the concept of the file itself is distinct from the name (which is called a "link"). A file may have zero, one, or many separate names. When you have a file open, it is the file itself that you have a reference to - it's OK to change or remove the name (and the file will remain open).

Upvotes: 3

Related Questions