summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhalex <halex@openbsd.org>2012-07-10 12:58:26 +0000
committerhalex <halex@openbsd.org>2012-07-10 12:58:26 +0000
commit38bb3b35534915196c4f6f5e9ed18a69b1db4dff (patch)
tree1f9e1898ceed763931c52c658875b57306625dbb
parentmake pkill -l print the proper processes also when the invert (-v) (diff)
downloadwireguard-openbsd-38bb3b35534915196c4f6f5e9ed18a69b1db4dff.tar.xz
wireguard-openbsd-38bb3b35534915196c4f6f5e9ed18a69b1db4dff.zip
disable lidsuspend on shutdown
ok phessler@ mpf@ pirofti@ mpi@
-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");