From d240d05cef9bd530fa2189e516c4e62718c8ec8c Mon Sep 17 00:00:00 2001 From: Mattia Giambirtone Date: Sat, 12 Mar 2022 15:51:31 +0100 Subject: [PATCH] Minor changes to nimDExit and shutdown.nim --- src/core/shutdown.nim | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/core/shutdown.nim b/src/core/shutdown.nim index b74f24d..e4d029e 100644 --- a/src/core/shutdown.nim +++ b/src/core/shutdown.nim @@ -32,16 +32,14 @@ type ShutdownHandler* = ref object const reboot_codes = {"poweroff": 0x4321fedc'i64, "reboot": 0x01234567'i64, "halt": 0xcdef0123}.toTable() +var shutdownHandlers: seq[ShutdownHandler] = @[] +var sigTermDelay: float = 90 proc newShutdownHandler*(body: proc (logger: Logger, code: int)): ShutdownHandler = result = ShutdownHandler(body: body) -var shutdownHandlers: seq[ShutdownHandler] = @[] -var sigTermDelay: float = 90 - - proc setSigTermDelay*(delay: int = 90) = # Sets the sigtermDelay variable sigTermDelay = float(delay) @@ -97,8 +95,8 @@ proc nimDExit*(logger: Logger, code: int, emerg: bool = true) = # We're in emergency mode: do not crash the kernel, spawn a shell and exit logger.fatal("NimD has entered emergency mode and cannot continue. You will be now (hopefully) dropped in a root shell: you're on your own. May the force be with you") logger.info("Terminating child processes with SIGKILL") - discard execCmd(os.getEnv("SHELL", "/bin/sh")) # TODO: Is this fine? maybe use execProcess discard posix.kill(-1, SIGKILL) + discard execCmd(os.getEnv("SHELL", "/bin/sh")) # TODO: Is this fine? maybe use execProcess quit(-1) logger.warning("The system is shutting down") logger.info("Processing shutdown runlevel") @@ -121,6 +119,7 @@ proc nimDExit*(logger: Logger, code: int, emerg: bool = true) = logger.info("Terminating child processes with SIGKILL") discard posix.kill(-1, SIGKILL) logger.warning("Shutdown procedure complete, NimD is exiting") + quit(-1) proc reboot*(logger: Logger) =