From 02d8e5b1b1bd7d306aeabbefd27be8420b90e130 Mon Sep 17 00:00:00 2001 From: uebayasi Date: Sat, 12 Jul 2014 20:18:08 +0000 Subject: [PATCH] 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@ --- sys/arch/hppa/dev/power.c | 7 ++++--- sys/arch/hppa64/dev/power.c | 7 ++++--- 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 +#include +#include #include #include -#include #include #include @@ -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 +#include +#include #include #include -#include #include #include @@ -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 +#include +#include #include #include #include @@ -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); } -- 2.20.1