diff options
author | Masao Uebayashi <uebayasi@cvs.openbsd.org> | 2014-07-12 20:18:10 +0000 |
---|---|---|
committer | Masao Uebayashi <uebayasi@cvs.openbsd.org> | 2014-07-12 20:18:10 +0000 |
commit | 894698ab3f603897bffd7993a7f1074e85172047 (patch) | |
tree | e571d148ab102f6dbdd88730714fd93b02641e2b | |
parent | 93f226fdd7fd863d667ca20568296621176a26d3 (diff) |
reboot(9): Shutdown system by signaling init(8) from kernel where appropriate
Some ports watch temperature in MD and try to shutdown system, when overheated,
by calling directly (re)boot(9). Change this to signal init(8) from kernel,
as acpi(4) and acpitz(4) do, which has been more tested. This also helps to
clarify design that ``clean shutdown must be always started by init(8)''.
Note that SIGUSR2 causes init(8) to call reboot(2) with RB_POWERDOWN, as
acpi(4) etc. already does. It is reasonable, pointed out by kettenis@,
considering system is overheated and immediate reboot may be dangerous.
OK deraadt@ miod@
-rw-r--r-- | sys/arch/hppa/dev/power.c | 7 | ||||
-rw-r--r-- | sys/arch/hppa64/dev/power.c | 7 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/sbus.c | 7 |
3 files changed, 12 insertions, 9 deletions
diff --git a/sys/arch/hppa/dev/power.c b/sys/arch/hppa/dev/power.c index 0c0318b0bec..d13bdbef42f 100644 --- a/sys/arch/hppa/dev/power.c +++ b/sys/arch/hppa/dev/power.c @@ -1,4 +1,4 @@ -/* $OpenBSD: power.c,v 1.7 2014/07/12 14:12:44 uebayasi Exp $ */ +/* $OpenBSD: power.c,v 1.8 2014/07/12 20:18:08 uebayasi Exp $ */ /* * Copyright (c) 2003 Michael Shalayeff @@ -27,9 +27,10 @@ */ #include <sys/param.h> +#include <sys/proc.h> +#include <sys/signalvar.h> #include <sys/kernel.h> #include <sys/systm.h> -#include <sys/reboot.h> #include <sys/device.h> #include <sys/kthread.h> @@ -154,7 +155,7 @@ power_thread_dr(void *v) * switch and thus we have do dampen it ourselves. */ if (sc->sc_dr_cnt == hz / 10) - reboot(RB_POWERDOWN | RB_HALT); + prsignal(initprocess, SIGUSR2); tsleep(v, PWAIT, "drpower", 10); } diff --git a/sys/arch/hppa64/dev/power.c b/sys/arch/hppa64/dev/power.c index ee85fcf62a3..21a61396b29 100644 --- a/sys/arch/hppa64/dev/power.c +++ b/sys/arch/hppa64/dev/power.c @@ -1,4 +1,4 @@ -/* $OpenBSD: power.c,v 1.3 2014/07/12 14:12:44 uebayasi Exp $ */ +/* $OpenBSD: power.c,v 1.4 2014/07/12 20:18:08 uebayasi Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -18,9 +18,10 @@ */ #include <sys/param.h> +#include <sys/proc.h> +#include <sys/signalvar.h> #include <sys/kernel.h> #include <sys/systm.h> -#include <sys/reboot.h> #include <sys/device.h> #include <sys/kthread.h> @@ -123,7 +124,7 @@ power_thread_reg(void *v) : "=&r" (r) : "r" (sc->sc_pwr_reg)); if (!(r & 1)) - reboot(RB_POWERDOWN | RB_HALT); + prsignal(initprocess, SIGUSR2); tsleep(v, PWAIT, "regpower", 10); } diff --git a/sys/arch/sparc64/dev/sbus.c b/sys/arch/sparc64/dev/sbus.c index 15b5d886eb3..c4efd70b7cc 100644 --- a/sys/arch/sparc64/dev/sbus.c +++ b/sys/arch/sparc64/dev/sbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sbus.c,v 1.41 2014/07/12 18:44:43 tedu Exp $ */ +/* $OpenBSD: sbus.c,v 1.42 2014/07/12 20:18:09 uebayasi Exp $ */ /* $NetBSD: sbus.c,v 1.46 2001/10/07 20:30:41 eeh Exp $ */ /*- @@ -99,6 +99,8 @@ */ #include <sys/param.h> +#include <sys/proc.h> +#include <sys/signalvar.h> #include <sys/extent.h> #include <sys/malloc.h> #include <sys/systm.h> @@ -571,8 +573,7 @@ sbus_overtemp(void *arg) /* Should try a clean shutdown first */ printf("DANGER: OVER TEMPERATURE detected\nShutting down...\n"); delay(20); - reboot(RB_POWERDOWN | RB_HALT); - /*NOTREACHED*/ + prsignal(initprocess, SIGUSR2); return (1); } |