Originally posted by Jim Yingst:
I don't know what kind of server you're dealing with here, but it probably has some sort of shutdown method. Find that, and see if you can insert a close() call to the file as part of the shutdown sequence. Alternately if you normally shut down using control-C or something, you can try using a shutdown hook:
This can't always be guaranteed to work, depending on shutdown method (e.g. kill -9 probably won't bother respect the shutdown hook, I'm guessing) but it's as good as you're likely to be able to get on most systems.
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton