The reason this question comes up all the time is that there's no traditional interface in Unix to tell if someone has a file open, so every solution is ad hoc and very unix-flavor specific. So, you're not gonna find a solution that works everywhere. Generally, people have worked out alternate strategies, like write to a temp file and rename after closing.