merge branch changes into trunk
[project/luci.git] / libs / nixio / src / process.c
index 0e8ac8a..5ae9b82 100644 (file)
@@ -65,14 +65,14 @@ int nixio__exec(lua_State *L, int m) {
                                        return luaL_error(L, "stack overflow");
                                }
 
-                               if (!lua_type(L, -2) != LUA_TSTRING || !lua_isstring(L, -1)) {
+                               if (lua_type(L, -2) != LUA_TSTRING || !lua_isstring(L, -1)) {
                                        return luaL_argerror(L, 3, "invalid environment");
                                }
 
                                lua_pushfstring(L, "%s=%s",
                                                lua_tostring(L, -2), lua_tostring(L, -1));
 
-                               lua_insert(L, 4);
+                               lua_insert(L, 5);
                                lua_pop(L, 1);
                                argn++;
                        }
@@ -80,8 +80,8 @@ int nixio__exec(lua_State *L, int m) {
                        char **env = lua_newuserdata(L, sizeof(char*) * (argn + 1));
                        env[argn] = NULL;
 
-                       for (i = 1; i < argn; i++) {
-                               env[i-1] = (char *)lua_tostring(L, -i);
+                       for (i = 1; i <= argn; i++) {
+                               env[i-1] = (char *)lua_tostring(L, -(i+1));
                        }
 
                        execve(path, args, env);
@@ -225,16 +225,16 @@ static int nixio_times(lua_State *L) {
                return nixio__perror(L);
        } else {
                lua_createtable(L, 0, 4);
-               lua_pushnumber(L, buf.tms_cstime);
+               nixio__pushnumber(L, buf.tms_cstime);
                lua_setfield(L, -2, "cstime");
 
-               lua_pushnumber(L, buf.tms_cutime);
+               nixio__pushnumber(L, buf.tms_cutime);
                lua_setfield(L, -2, "cutime");
 
-               lua_pushnumber(L, buf.tms_stime);
+               nixio__pushnumber(L, buf.tms_stime);
                lua_setfield(L, -2, "stime");
 
-               lua_pushnumber(L, buf.tms_utime);
+               nixio__pushnumber(L, buf.tms_utime);
                lua_setfield(L, -2, "utime");
 
                return 1;
@@ -365,16 +365,16 @@ static int nixio_sysinfo(lua_State *L) {
 
        lua_createtable(L, 0, 12);
 
-       lua_pushnumber(L, info.bufferram);
+       nixio__pushnumber(L, info.bufferram);
        lua_setfield(L, -2, "bufferram");
 
-       lua_pushnumber(L, info.freehigh);
+       nixio__pushnumber(L, info.freehigh);
        lua_setfield(L, -2, "freehigh");
 
-       lua_pushnumber(L, info.freeram);
+       nixio__pushnumber(L, info.freeram);
        lua_setfield(L, -2, "freeram");
 
-       lua_pushnumber(L, info.freeswap);
+       nixio__pushnumber(L, info.freeswap);
        lua_setfield(L, -2, "freeswap");
 
        lua_createtable(L, 0, 3);
@@ -384,25 +384,25 @@ static int nixio_sysinfo(lua_State *L) {
        }
        lua_setfield(L, -2, "loads");
 
-       lua_pushnumber(L, info.mem_unit);
+       lua_pushinteger(L, info.mem_unit);
        lua_setfield(L, -2, "mem_unit");
 
-       lua_pushnumber(L, info.procs);
+       lua_pushinteger(L, info.procs);
        lua_setfield(L, -2, "procs");
 
-       lua_pushnumber(L, info.sharedram);
+       nixio__pushnumber(L, info.sharedram);
        lua_setfield(L, -2, "sharedram");
 
-       lua_pushnumber(L, info.totalhigh);
+       nixio__pushnumber(L, info.totalhigh);
        lua_setfield(L, -2, "totalhigh");
 
-       lua_pushnumber(L, info.totalram);
+       nixio__pushnumber(L, info.totalram);
        lua_setfield(L, -2, "totalram");
 
-       lua_pushnumber(L, info.totalswap);
+       nixio__pushnumber(L, info.totalswap);
        lua_setfield(L, -2, "totalswap");
 
-       lua_pushnumber(L, info.uptime);
+       lua_pushinteger(L, info.uptime);
        lua_setfield(L, -2, "uptime");
 
        return 1;