From d9192f10befb93d4f51df7e924c1473ab724f0f5 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 6 Oct 2022 10:39:43 +0200 Subject: [PATCH] Add SIGTERM handling, adjust limit finding step --- app/src/fan/HwmonFan.cxx | 7 ++++--- app/src/main.cxx | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/fan/HwmonFan.cxx b/app/src/fan/HwmonFan.cxx index eb7a7f7..ee7d38c 100644 --- a/app/src/fan/HwmonFan.cxx +++ b/app/src/fan/HwmonFan.cxx @@ -8,6 +8,7 @@ #include #define TIMEOUT 10 +#define STEP 2 using namespace std; @@ -43,12 +44,12 @@ void HwmonFan::FindPWMLimits() { mMinPWM = 0; mStartPWM = 0; - for (int curPWM = 100; curPWM > 0; curPWM -= 5) { + for (int curPWM = 100; curPWM > 0; curPWM -= STEP) { PWM(curPWM); this_thread::sleep_for(chrono::seconds(TIMEOUT)); if (RPM() <= 0) { - minPWM = curPWM + 5; + minPWM = curPWM + STEP; break; } } @@ -62,7 +63,7 @@ void HwmonFan::FindPWMLimits() { int startPWM = 0; cout << "Looking for start PWM!" << endl; - for (int curPWM = minPWM - 5; curPWM < 100; curPWM += 5) { + for (int curPWM = minPWM - STEP; curPWM < 100; curPWM += STEP) { PWM(curPWM); this_thread::sleep_for(chrono::seconds(TIMEOUT)); diff --git a/app/src/main.cxx b/app/src/main.cxx index a4c7c8a..93d32eb 100644 --- a/app/src/main.cxx +++ b/app/src/main.cxx @@ -1,4 +1,3 @@ -#include #include #include @@ -6,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -60,6 +60,7 @@ void InitLogging(bool verbose) { int main(int argc, char **argv) { signal(SIGINT, signal_handler); + signal(SIGTERM, signal_handler); po::options_description desc("Allowed options"); desc.add_options()("help,h", "produce help message")(