From 356c93a5ae52bda276a2907b96786d968d916ca6 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Mon, 11 Feb 2019 18:57:17 +0100 Subject: [PATCH] le2lib: return errno value from waitpid Signed-off-by: Tobias Ulmer --- generic/le2lib.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/generic/le2lib.c b/generic/le2lib.c index 3a86b42..fb2b381 100644 --- a/generic/le2lib.c +++ b/generic/le2lib.c @@ -282,31 +282,28 @@ process_wait(lua_State *lua) int rc, status; rc = waitpid(pid, &status, 0); if (rc < 0) { + int e = errno; lua_pushboolean(lua, 0); - lua_pushstring(lua, strerror(errno)); - return 2; + lua_pushstring(lua, strerror(e)); + lua_pushinteger(lua, e); + return 3; } if (WIFEXITED(status)) { /* Normal exit case */ lua_pushnumber(lua, WEXITSTATUS(status)); lua_pushnumber(lua, rc); - return 2; } else if (WIFSIGNALED(status)) { /* Signal exit case */ lua_pushnumber(lua, WTERMSIG(status) + 128); // what dash does lua_pushnumber(lua, rc); lua_pushnumber(lua, WTERMSIG(status)); - return 3; - } else { - /* Job control status but option is unset */ - lua_pushboolean(lua, 0); - lua_pushstring(lua, "internal error, please report (waitpid)"); - - return 2; } + + /* Job control status but option is unset */ + return luaL_error(lua, "process_wait: unhandled case, please report"); } static int -- 2.39.5