This pull request is intended to facilitate bitcoind log rotation. When the daemon receives a HUP signal, it reopens the debug.log file so the previous one can be rotated. I’ve tried to describe the technical motivation in each of the three commit messages. It uses flockfile and funlockfile to avoid thread contention issues. As best I can tell, those functions are available on most platforms, but I have only compiled on OS X.
I have a test script which sends SIGHUP to the bitcoind process every 100 ms. I’ve been running with that test script and this patch for the last few days and haven’t had any problems. In my tests, it behaves well during startup and shutdown too. Each rotated log contains the content I expect.
Suggestions for improvement welcome.