diff options
author | PA4WDH | 2023-05-21 11:18:09 +0200 |
---|---|---|
committer | PA4WDH | 2023-05-21 11:18:09 +0200 |
commit | dd7849cd6c1d0a79d5574203f3f41cac4f22e5d6 (patch) | |
tree | 7e1013c2d2fc0d2d0189be49c1afad74cd347639 /cputemp2maxfreq.c | |
parent | Add .nfs* to gitignore (diff) | |
download | cputemp2maxfreq-dd7849cd6c1d0a79d5574203f3f41cac4f22e5d6.tar.gz cputemp2maxfreq-dd7849cd6c1d0a79d5574203f3f41cac4f22e5d6.tar.bz2 cputemp2maxfreq-dd7849cd6c1d0a79d5574203f3f41cac4f22e5d6.zip |
Add signal handler
Diffstat (limited to 'cputemp2maxfreq.c')
-rw-r--r-- | cputemp2maxfreq.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cputemp2maxfreq.c b/cputemp2maxfreq.c index 20a3046..ebf5026 100644 --- a/cputemp2maxfreq.c +++ b/cputemp2maxfreq.c @@ -3,6 +3,7 @@ #include <stdlib.h> #include <errno.h> #include <string.h> +#include <signal.h> #include "sysfs.h" #include "cpufreq.h" #include "debug.h" @@ -21,6 +22,12 @@ struct s_cpudata cpudata; struct s_config config={"conservative",70000,"/sys/devices/virtual/thermal/thermal_zone0/temp",100000,2000000,10}; +void signal_handler(int signum) +{ + printf("Received signal %d, exiting.\n",signum); + failsafe(0); +} + int main() { long int diff; @@ -65,6 +72,11 @@ int main() failsafe(1); } +// Set signal handlers + signal(SIGTERM,signal_handler); + signal(SIGINT,signal_handler); + signal(SIGQUIT,signal_handler); + while(1) { // Get new measurements |