2016-04-21 15:24:43 +02:00
|
|
|
--- luaext/lposix.c
|
|
|
|
+++ luaext/lposix.c
|
2015-08-10 15:16:09 +02:00
|
|
|
@@ -361,22 +361,35 @@ static int Pfork(lua_State *L) /** for
|
|
|
|
|
|
|
|
static int Pwait(lua_State *L) /** wait([pid]) */
|
|
|
|
{
|
|
|
|
+#if LUA_VERSION_NUM < 503
|
|
|
|
pid_t pid = luaL_optint(L, 1, -1);
|
|
|
|
+#else
|
|
|
|
+ pid_t pid = (int)luaL_optinteger(L, 1, -1);
|
|
|
|
+#endif
|
|
|
|
return pushresult(L, waitpid(pid, NULL, 0), NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int Pkill(lua_State *L) /** kill(pid,[sig]) */
|
|
|
|
{
|
|
|
|
+#if LUA_VERSION_NUM < 503
|
|
|
|
pid_t pid = luaL_checkint(L, 1);
|
|
|
|
int sig = luaL_optint(L, 2, SIGTERM);
|
|
|
|
+#else
|
|
|
|
+ pid_t pid = (int)luaL_checkinteger(L, 1);
|
|
|
|
+ int sig = (int)luaL_optinteger(L, 2, SIGTERM);
|
|
|
|
+#endif
|
|
|
|
return pushresult(L, kill(pid, sig), NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int Psleep(lua_State *L) /** sleep(seconds) */
|
|
|
|
{
|
|
|
|
+#if LUA_VERSION_NUM < 503
|
|
|
|
unsigned int seconds = luaL_checkint(L, 1);
|
|
|
|
+#else
|
|
|
|
+ unsigned int seconds = (int)luaL_checkinteger(L, 1);
|
|
|
|
+#endif
|
|
|
|
lua_pushnumber(L, sleep(seconds));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
@@ -529,7 +542,11 @@ static int Pgetprocessid(lua_State *L)
|
|
|
|
|
|
|
|
static int Pttyname(lua_State *L) /** ttyname(fd) */
|
|
|
|
{
|
|
|
|
+#if LUA_VERSION_NUM < 503
|
|
|
|
int fd=luaL_optint(L, 1, 0);
|
|
|
|
+#else
|
|
|
|
+ int fd = (int)luaL_optinteger(L, 1, 0);
|
|
|
|
+#endif
|
|
|
|
lua_pushstring(L, ttyname(fd));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
@@ -879,8 +896,11 @@ static int exit_override(lua_State *L)
|
|
|
|
{
|
|
|
|
if (!have_forked)
|
|
|
|
return luaL_error(L, "exit not permitted in this context");
|
|
|
|
-
|
|
|
|
+#if LUA_VERSION_NUM < 503
|
|
|
|
exit(luaL_optint(L, 1, EXIT_SUCCESS));
|
|
|
|
+#else
|
|
|
|
+ exit((int)luaL_optinteger(L, 1, EXIT_SUCCESS));
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static const luaL_Reg os_overrides[] =
|