From: Tobias Ulmer Date: Fri, 15 Feb 2019 10:42:08 +0000 (+0100) Subject: e2lib: finish: if we received a signal, exit with the signal code X-Git-Tag: e2factory-2.3.18rc1~43 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=0041748cbf34dd4f9b26c16d313392e371476ec9;p=e2factory.git e2lib: finish: if we received a signal, exit with the signal code Receiving a signal causes subsequent errors which hide the true cause for termination. Make sure we always exit with 128 + signalno and let the user know that above errors were caused by a signal. Signed-off-by: Tobias Ulmer --- diff --git a/generic/e2lib.lua b/generic/e2lib.lua index 44a50f1..8837ceb 100644 --- a/generic/e2lib.lua +++ b/generic/e2lib.lua @@ -878,18 +878,30 @@ end -- @param rc number: return code (optional, defaults to 0) -- @return This function does not return. function e2lib.finish(returncode) + local sigstr, signum + local finalreturn if not returncode then returncode = 0 end e2lib.cleanup() - e2lib.logf(4, "exiting e2factory with returncode=%d", returncode) + finalreturn = returncode + sigstr, signum = e2lib.signal_received() + if sigstr ~= "" then + e2lib.logf(1,"Error: *** received signal %d \"%s\" ***", signum, sigstr) + finalreturn = 128 + signum + end + + children_assert_empty() + + e2lib.logf(4, "exiting e2factory with pid=%d returncode=%d finalreturn=%d", + e2lib.getpid(), returncode, finalreturn) if e2lib.globals.debuglogfile then eio.fclose(e2lib.globals.debuglogfile) e2lib.globals.debuglogfile = false end console.close() - os.exit(returncode) + os.exit(finalreturn) end --- Returns the "directory" part of a path