diff options
Diffstat (limited to 'sbin/init/init.c')
-rw-r--r-- | sbin/init/init.c | 14 |
1 files changed, 14 insertions, 0 deletions
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; } |