From: Tobias Ulmer Date: Fri, 22 Nov 2013 11:29:45 +0000 (+0100) Subject: Add return of terminating signal in e2lib.wait() X-Git-Tag: e2factory-2.3.15rc1~347 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=208c0a7f6adce3da5495dba249d8be2e40f82ae6;p=e2factory.git Add return of terminating signal in e2lib.wait() Signed-off-by: Tobias Ulmer --- diff --git a/generic/e2lib.lua b/generic/e2lib.lua index 20507f2..4a32aa0 100644 --- a/generic/e2lib.lua +++ b/generic/e2lib.lua @@ -199,14 +199,15 @@ end -- @param pid Process ID, -1 to wait for any child. -- @return Exit status of process (WEXITSTATUS), or false on error. -- @return Process ID of the terminated child or error object on failure. +-- @return Number of signal that killed the process, if any. function e2lib.wait(pid) - local rc, childpid = le2lib.wait(pid) + local rc, childpid, sig = le2lib.wait(pid) if not rc then return false, err.new("waiting for child %d failed: %s", pid, childpid) end - return rc, childpid + return rc, childpid, sig end --- Poll input output multiplexing. diff --git a/generic/le2lib.c b/generic/le2lib.c index fb69302..8f7ce6f 100644 --- a/generic/le2lib.c +++ b/generic/le2lib.c @@ -295,8 +295,18 @@ process_wait(lua_State *lua) return 2; } + if (!(WIFEXITED(status) || WIFSIGNALED(status))) { + lua_pushboolean(lua, 0); + lua_pushstring(lua, "process terminated(?) due to unknown cause"); + return 2; + } + lua_pushnumber(lua, WEXITSTATUS(status)); lua_pushnumber(lua, rc); + if (WIFSIGNALED(status)) { + lua_pushnumber(lua, WTERMSIG(status)); + return 3; + } return 2; }