luaa: replace os.execute()

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-08-27 12:08:02 +02:00
parent 34d37c00c8
commit c006ce10dd
1 changed files with 17 additions and 0 deletions

17
luaa.c
View File

@ -283,6 +283,18 @@ CHECK_TYPE(widget);
return 1;
}
/** Modified version of os.execute() which use spawn code to reset signal
* handlers correctly before exec()ing the new program.
* \param L The Lua VM state.
* \return The number of arguments pushed on stack.
*/
static int
luaAe_os_execute(lua_State *L)
{
lua_pushinteger(L, spawn_system(luaL_optstring(L, 1, NULL)));
return 1;
}
/** Replace various standards Lua functions with our own.
* \param L The Lua VM state.
*/
@ -294,6 +306,11 @@ luaA_fixups(lua_State *L)
lua_pushcfunction(L, luaA_mbstrlen);
lua_setfield(L, -2, "wlen");
lua_pop(L, 1);
/* replace os.execute */
lua_getglobal(L, "os");
lua_pushcfunction(L, luaAe_os_execute);
lua_setfield(L, -2, "execute");
lua_pop(L, 1);
/* replace next */
lua_pushliteral(L, "next");
lua_pushcfunction(L, luaAe_next);