summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoruebayasi <uebayasi@openbsd.org>2014-07-12 20:18:08 +0000
committeruebayasi <uebayasi@openbsd.org>2014-07-12 20:18:08 +0000
commit02d8e5b1b1bd7d306aeabbefd27be8420b90e130 (patch)
tree840d605c620a19183c004c6cbfa95e279a1d2422
parentClose connections when msgbuf_write() returns 0. (diff)
downloadwireguard-openbsd-02d8e5b1b1bd7d306aeabbefd27be8420b90e130.tar.xz
wireguard-openbsd-02d8e5b1b1bd7d306aeabbefd27be8420b90e130.zip
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.c7
-rw-r--r--sys/arch/hppa64/dev/power.c7
-rw-r--r--sys/arch/sparc64/dev/sbus.c7
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);
}