aboutsummaryrefslogtreecommitdiffstats
path: root/cputemp2maxfreq.c
diff options
context:
space:
mode:
Diffstat (limited to 'cputemp2maxfreq.c')
-rw-r--r--cputemp2maxfreq.c12
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