Minor fixes + removed redundant SIGINT hook

This commit is contained in:
Nocturn9x 2021-12-02 21:28:58 +01:00
parent b01da7eada
commit 6ef157baa0
4 changed files with 2 additions and 8 deletions

View File

@ -47,7 +47,6 @@ proc main(logger: Logger) =
when isMainModule:
setControlCHook(handleControlC)
var logger = getDefaultLogger()
var optParser = initOptParser(commandLineParams())
for kind, key, value in optParser.getopt():

View File

@ -170,7 +170,6 @@ proc mountRealDisks*(logger: Logger, fstab: string = "/etc/fstab") =
proc mountVirtualDisks*(logger: Logger) =
## Mounts POSIX virtual filesystems/partitions,
## such as /proc and /sys
var retcode = 0
for entry in virtualFileSystems:
if checkDisksIsMounted(entry):
@ -213,7 +212,7 @@ proc unmountAllDisks*(logger: Logger, code: int) =
continue
logger.debug(&"Unmounting filesystem {entry.source} ({entry.filesystemtype}) from {entry.target}")
logger.trace(&"Calling umount2('{entry.target}', MNT_DETACH)")
var retcode = umount2(entry.target, 2) # 2 = MNT_DETACH - Since we're shutting down, we need the disks to be *gone*!
retcode = umount2(entry.target, 2) # 2 = MNT_DETACH - Since we're shutting down, we need the disks to be *gone*!
logger.trace(&"umount2('{entry.target}', MNT_DETACH) returned {retcode}")
if retcode == -1:
logger.error(&"Unmounting disk {entry.source} from {entry.target} has failed with error {posix.errno}: {posix.strerror(posix.errno)}")

View File

@ -122,4 +122,4 @@ proc getDefaultLogger*(): Logger =
result.addHandler(createHandler(logWarning, LogLevel.Warning))
result.addHandler(createHandler(logError, LogLevel.Error))
result.addHandler(createHandler(logCritical, LogLevel.Critical))
result.addHandler(createHandler(logFatal, LogLevel.Fatal))
result.addHandler(createHandler(logFatal, LogLevel.Fatal))

View File

@ -86,8 +86,4 @@ proc setHostname*(logger: Logger): string =
proc sleepSeconds*(amount: SomeInteger) = sleep(amount * 1000)
proc handleControlC* {.noconv.} =
raise newException(CtrlCException, "Interrupted by Ctrl+C")
proc strsignal*(sig: cint): cstring {.header:"string.h", importc.}