]> git.e2factory.org Git - e2factory.git/commitdiff
le2lib: return errno value from waitpid
authorTobias Ulmer <tu@emlix.com>
Mon, 11 Feb 2019 17:57:17 +0000 (18:57 +0100)
committerTobias Ulmer <tu@emlix.com>
Mon, 11 Feb 2019 17:57:17 +0000 (18:57 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/le2lib.c

index 3a86b42ae4ee966745d5a6f67659340dee4813f9..fb2b38170372adaff64c3b64a9a32ed523d16e67 100644 (file)
@@ -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