summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorcperciva <cperciva@FreeBSD.org>2015-10-01 10:52:26 +0000
committercperciva <cperciva@FreeBSD.org>2015-10-01 10:52:26 +0000
commit8e136c4370617d6cb5580f3c9e51ae1c58f7edbe (patch)
tree7989543c22e5c121e120ae359b7126a9764569f1 /sbin
parent10e70b971f2cc53a76bf17bffc580cab730750ed (diff)
downloadFreeBSD-src-8e136c4370617d6cb5580f3c9e51ae1c58f7edbe.zip
FreeBSD-src-8e136c4370617d6cb5580f3c9e51ae1c58f7edbe.tar.gz
Disable suspend when we're shutting down. This solves the "tell FreeBSD
to shut down; close laptop lid" scenario which otherwise tended to end with a laptop overheating or the battery dying. The implementation uses a new sysctl, kern.suspend_blocked; init(8) sets this while rc.suspend runs, and the ACPI sleep code ignores requests while the sysctl is set. Discussed on: freebsd-acpi (35 emails) MFC after: 1 week
Diffstat (limited to 'sbin')
-rw-r--r--sbin/init/init.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/sbin/init/init.c b/sbin/init/init.c
index 5ab3527..edc38e6 100644
--- a/sbin/init/init.c
+++ b/sbin/init/init.c
@@ -1487,6 +1487,15 @@ static state_func_t
death(void)
{
session_t *sp;
+ int block, blocked;
+ size_t len;
+
+ /* Temporarily block suspend. */
+ len = sizeof(blocked);
+ block = 1;
+ if (sysctlbyname("kern.suspend_blocked", &blocked, &len,
+ &block, sizeof(block)) == -1)
+ blocked = 0;
/*
* Also revoke the TTY here. Because runshutdown() may reopen
@@ -1503,6 +1512,11 @@ death(void)
/* Try to run the rc.shutdown script within a period of time */
runshutdown();
+ /* Unblock suspend if we blocked it. */
+ if (!blocked)
+ sysctlbyname("kern.suspend_blocked", NULL, NULL,
+ &blocked, sizeof(blocked));
+
return (state_func_t) death_single;
}
OpenPOWER on IntegriCloud