What would happen if I reopen an fstream
with data in it using the std::ios::trunc
flag without closing a process and whilst my process holds a boost::interprocess::file_lock()
?
Should I expect the OS to maintain my file lock? Or will the OS transparently unregister the lock when the file is closed? Both Windows and POSIX experience would be appreciated.
edit
my main goal is to truncate a config file and rewrite it. The secondary purpose of the file is to prevent other equivalent daemons from starting up. So if there is another way using boost or c++ stl to truncate a file without closing it, I'm all ears :D