diff --git a/CHANGES b/CHANGES index 1c6e5333..c976c7f4 100644 --- a/CHANGES +++ b/CHANGES @@ -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 diff --git a/prog/sensord/lib.c b/prog/sensord/lib.c index ff5de5f8..dd1d0e11 100644 --- a/prog/sensord/lib.c +++ b/prog/sensord/lib.c @@ -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); diff --git a/prog/sensord/sensord.8 b/prog/sensord/sensord.8 index 19408dba..6aec0155 100644 --- a/prog/sensord/sensord.8 +++ b/prog/sensord/sensord.8 @@ -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) diff --git a/prog/sensord/sensord.c b/prog/sensord/sensord.c index 872bb56a..b8f06a1f 100644 --- a/prog/sensord/sensord.c +++ b/prog/sensord/sensord.c @@ -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); }