From 7b86f845febc3b375bb02008a456a5514a9396c9 Mon Sep 17 00:00:00 2001 From: cperciva Date: Thu, 8 Oct 2015 15:48:44 +0000 Subject: MFC r288446: Disable suspend during shutdown. --- sbin/init/init.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'sbin/init/init.c') diff --git a/sbin/init/init.c b/sbin/init/init.c index 99041c9..e6f567c 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -1499,6 +1499,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 @@ -1515,6 +1524,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; } -- cgit v1.1