aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorMichael Hendricks <michael@ndrix.org>2012-03-02 12:31:16 -0700
committerMichael Hendricks <michael@ndrix.org>2012-05-18 16:20:03 -0600
commit9af080c351c40a4f56d37174253d33a9f4ffdb69 (patch)
treeb3b9f85c0f7cbca2ca880ba36a5e4bbca8e006d0 /src/init.cpp
parentfea25712ca54c4715f874cf3d871e84bbfd83352 (diff)
downloadbitcoin-9af080c351c40a4f56d37174253d33a9f4ffdb69.tar.xz
Reopen debug.log on SIGHUP
The best log rotation method formerly available was to configure logrotate with the copytruncate option. As described in the logrotate documentation, "there is a very small time slice between copying the file and truncating it, so some logging data might be lost". By sending SIGHUP to the server process, one can now reopen the debug log file without losing any data.
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/init.cpp b/src/init.cpp
index b027a53d81..726950bdb6 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -80,6 +80,10 @@ void HandleSIGTERM(int)
fRequestShutdown = true;
}
+void HandleSIGHUP(int)
+{
+ fReopenDebugLog = true;
+}
@@ -285,7 +289,13 @@ bool AppInit2()
sa.sa_flags = 0;
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGINT, &sa, NULL);
- sigaction(SIGHUP, &sa, NULL);
+
+ // Reopen debug.log on SIGHUP
+ struct sigaction sa_hup;
+ sa_hup.sa_handler = HandleSIGHUP;
+ sigemptyset(&sa_hup.sa_mask);
+ sa_hup.sa_flags = 0;
+ sigaction(SIGHUP, &sa_hup, NULL);
#endif
fTestNet = GetBoolArg("-testnet");