luaa: replace os.execute()
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
d31b7666a1
commit
a6c4459a3a
17
luaa.c
17
luaa.c
|
@ -236,6 +236,18 @@ luaAe_type(lua_State *L)
|
|||
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.
|
||||
*/
|
||||
|
@ -247,6 +259,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);
|
||||
|
|
Loading…
Reference in New Issue