From: Matthew Dillon Date: Mon, 14 Jul 2014 18:16:53 +0000 (-0700) Subject: powerd - Set to max performance if killed X-Git-Tag: v4.1.0~425 X-Git-Url: https://gitweb.dragonflybsd.org/~tuxillo/dragonfly.git/commitdiff_plain/323ed6828c242483c92281370db9c63f46ca9de4 powerd - Set to max performance if killed * If the powerd daemon is killed it now sets the system to maximum performance before exiting for consistency, instead of leaving it in a potentially low-power state. --- diff --git a/usr.sbin/powerd/powerd.c b/usr.sbin/powerd/powerd.c index 43c7948f15..9bb7d76b67 100644 --- a/usr.sbin/powerd/powerd.c +++ b/usr.sbin/powerd/powerd.c @@ -64,6 +64,8 @@ int CpuCount[256]; /* # of cpus in any given domain */ int CpuToDom[256]; /* domain a particular cpu belongs to */ double Trigger = 0.25; /* load per cpu to force max freq */ +static void sigintr(int signo); + int main(int ac, char **av) { @@ -143,6 +145,12 @@ main(int ac, char **av) break; } + /* + * Set to maximum performance if killed. + */ + signal(SIGINT, sigintr); + signal(SIGTERM, sigintr); + /* * Monitoring loop * @@ -168,6 +176,15 @@ main(int ac, char **av) } } +static +void +sigintr(int signo __unused) +{ + syslog(LOG_INFO, "killed, setting max and exiting"); + acpi_setcpufreq(NCpus); + exit(1); +} + /* * Figure out the domains and calculate the CpuCount[] and CpuToDom[] * arrays.