On 2021-05-19 11:19:11 +0200, Rainer Gerhards wrote: > Not sure if that helps with the issue, but rsyslog closes and re-opens > all logfiles on HUP.
So, what is needed is to make the protocol synchronous between rsyslog-rotate and the rsyslogd daemon, e.g. with a lock, in order to avoid the loss of the signal by a concurrent rsyslog-rotate. At https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=988093#37 I proposed the following idea: /usr/lib/rsyslog/rsyslog-rotate puts a lock, and once the lock is acquired, it sends the SIGHUP. When it sees that the SIGHUP has been processed[*], it releases the lock. [*] Currently one can see in the logs that rsyslogd processed the signal. This is done in tools/rsyslogd.c: /* This function processes a HUP after one has been detected. Note that this * is *NOT* the sighup handler. The signal is recorded by the handler, that record * detected inside the mainloop and then this function is called to do the * real work. -- rgerhards, 2008-10-22 * Note: there is a VERY slim chance of a data race when the hostname is reset. * We prefer to take this risk rather than sync all accesses, because to the best * of my analysis it can not really hurt (the actual property is reference-counted) * but the sync would require some extra CPU for *each* message processed. * rgerhards, 2012-04-11 */ static void doHUP(void) { char buf[512]; if(ourConf->globals.bLogStatusMsgs) { snprintf(buf, sizeof(buf), "[origin software=\"rsyslogd\" " "swVersion=\"" VERSION "\" x-pid=\"%d\" x-info=\"https://www.rsyslog.com\"] rsyslogd was HUPed", (int) glblGetOurPid()); errno = 0; logmsgInternal(NO_ERRCODE, LOG_SYSLOG|LOG_INFO, (uchar*)buf, 0); } queryLocalHostname(); /* re-read our name */ ruleset.IterateAllActions(ourConf, doHUPActions, NULL); modDoHUP(); lookupDoHUP(); errmsgDoHUP(); } As said, this is not done in the signal handler, but after, so that a second SIGHUP sent later should not be lost. However, getting information in the log is not practical. Since the rsyslogd daemon and the /usr/lib/rsyslog/rsyslog-rotate script come from the same package, something better could be done. For instance, the lock could be a file "/run/rsyslogd-hup.lock", created with length 0. When the daemon has processed a SIGHUP, it could write to this lock file (if existing). Once the rsyslog-rotate script notices that the length is not 0, it removes the lock and quits. -- Vincent Lefèvre <[email protected]> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

