sensord: Reload config on SIGHUP rather than automatically.

Reloading the configuration on SIGHUP is common for daemons. Reloading
automatically is less efficient and can be confusing or even racy.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4969 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare committed 2007-10-20 14:05:35 +00:00
1 parent 4db0a3284c
commit 3d9acfa6f9
4 files changed
+15 -8

No files matched your search

+1
View File
@@ -2,6 +2,7 @@ lm-sensors CHANGES file
-----------------------
SVN HEAD
sensord: Reload config on SIGHUP rather than automatically
sensors-detect: Fix SMSC LPC47B357/M967 detection
Select the right driver for FSC chips
+1 -5
View File
@@ -31,8 +31,6 @@
#include "sensord.h"
#include "lib/error.h"
static time_t cfgLastModified;
static int
loadConfig
(const char *cfgPath, int reload) {
@@ -51,7 +49,7 @@ loadConfig
} else if (stat (cfgPath, &stats) < 0) {
sensorLog (LOG_ERR, "Error stating sensors configuration file: %s", cfgPath);
ret = 10;
} else if (!reload || (difftime (stats.st_mtime, cfgLastModified) > 0.0)) {
} else {
if (reload) {
sensorLog (LOG_INFO, "configuration reloading");
sensors_cleanup ();
@@ -63,8 +61,6 @@ loadConfig
sensorLog (LOG_ERR, "Error loading sensors configuration file %s: %s",
cfgPath, sensors_strerror (ret));
ret = 11;
} else {
cfgLastModified = stats.st_mtime;
}
if (cfg)
fclose (cfg);
+3
View File
@@ -133,6 +133,9 @@ modules for chips in which you have no interest.
Upon receipt of a SIGTERM (see
.BR signal (7)
for details) this daemon should gracefully shut down.
Upon receipt of a SIGHUP, this daemon will rescan the kernel interface
for chips and features, and reload the libsensors configuration file.
.SH LOGGING
All messages from this daemon are logged to
.BR syslog (3)
+10 -3
View File
@@ -37,6 +37,7 @@
static int logOpened = 0;
static volatile sig_atomic_t done = 0;
static volatile sig_atomic_t reload = 0;
#define LOG_BUFFER 4096
@@ -69,6 +70,9 @@ signalHandler
case SIGTERM:
done = 1;
break;
case SIGHUP:
reload = 1;
break;
}
}
@@ -86,8 +90,10 @@ sensord
sensorLog (LOG_INFO, "sensord started");
while (!done && (ret == 0)) {
if (ret == 0)
if (reload) {
ret = reloadLib (sensorsCfgFile);
reload = 0;
}
if ((ret == 0) && scanTime) { /* should I scan on the read cycle? */
ret = scanChips ();
if (scanValue <= 0)
@@ -156,8 +162,9 @@ daemonize
}
/* I should use sigaction but... */
if (signal (SIGTERM, signalHandler) == SIG_ERR) {
perror ("signal(SIGTERM)");
if (signal (SIGTERM, signalHandler) == SIG_ERR ||
signal (SIGHUP, signalHandler) == SIG_ERR) {
perror ("signal");
exit (EXIT_FAILURE);
}