mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
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.
This commit is contained in:
12
src/init.cpp
12
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");
|
||||
|
||||
Reference in New Issue
Block a user