disable lidsuspend when we are powering down
authorphessler <phessler@openbsd.org>
Sat, 7 Aug 2010 10:22:28 +0000 (10:22 +0000)
committerphessler <phessler@openbsd.org>
Sat, 7 Aug 2010 10:22:28 +0000 (10:22 +0000)
"I like this" marco@, "Sure" deraadt@

sbin/init/init.c

index 670a377..9065589 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: init.c,v 1.41 2009/10/27 23:59:33 deraadt Exp $       */
+/*     $OpenBSD: init.c,v 1.42 2010/08/07 10:22:28 phessler Exp $      */
 /*     $NetBSD: init.c,v 1.22 1996/05/15 23:29:33 jtc Exp $    */
 
 /*-
@@ -1298,6 +1298,17 @@ nice_death(void)
        static const int death_sigs[3] = { SIGHUP, SIGTERM, SIGKILL };
        int status;
 
+#if CPU_LIDSUSPEND
+       int lidsuspend_mib[] = {CTL_MACHDEP, CPU_LIDSUSPEND};
+       int dontsuspend = 0;
+
+       if ((death_howto & RB_POWERDOWN) &&
+           (sysctl(lidsuspend_mib, 2, NULL, NULL, &dontsuspend,
+                   sizeof(dontsuspend)) < 0))
+                       warning("cannot disable lid suspend");
+       }
+#endif
+
        for (sp = sessions; sp; sp = sp->se_next) {
                sp->se_flags &= ~SE_PRESENT;
                sp->se_flags |= SE_SHUTDOWN;