summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorAlexander Hall <halex@cvs.openbsd.org>2012-07-10 12:58:27 +0000
committerAlexander Hall <halex@cvs.openbsd.org>2012-07-10 12:58:27 +0000
commit6a04914fc00f1de3c17ec88e83fe28d12fb824e0 (patch)
tree8b86cef6c12200ef6d12f053de9b8b1a92e7dc10 /sbin
parent3dacf7fec6c652685a605407f9559332ef6dfacb (diff)
disable lidsuspend on shutdown
ok phessler@ mpf@ pirofti@ mpi@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/reboot/reboot.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c
index dc5f96d03ad..222dae836bd 100644
--- a/sbin/reboot/reboot.c
+++ b/sbin/reboot/reboot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: reboot.c,v 1.31 2010/07/23 20:14:23 millert Exp $ */
+/* $OpenBSD: reboot.c,v 1.32 2012/07/10 12:58:26 halex Exp $ */
/* $NetBSD: reboot.c,v 1.8 1995/10/05 05:36:22 mycroft Exp $ */
/*
@@ -33,7 +33,10 @@
#include <sys/types.h>
#include <sys/reboot.h>
#include <sys/fcntl.h>
+#include <sys/param.h>
+#include <sys/sysctl.h>
#include <sys/wait.h>
+#include <machine/cpu.h>
#include <signal.h>
#include <pwd.h>
#include <errno.h>
@@ -110,6 +113,20 @@ main(int argc, char *argv[])
if (geteuid())
errx(1, "%s", strerror(EPERM));
+#ifdef CPU_LIDSUSPEND
+ if (howto & RB_POWERDOWN) {
+ /* Disable suspending on laptop lid close */
+ int mib[2];
+ int lidsuspend = 0;
+
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_LIDSUSPEND;
+ if (sysctl(mib, 2, NULL, NULL, &lidsuspend,
+ sizeof(lidsuspend)) == -1)
+ warn("sysctl");
+ }
+#endif /* CPU_LIDSUSPEND */
+
if (qflag) {
reboot(howto);
err(1, "reboot");