diff options
Diffstat (limited to 'sbin')
-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 5ab3527c073d..edc38e66ea3e 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; } |