diff options
Diffstat (limited to 'bruiser')
-rw-r--r-- | bruiser/bruiser.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/bruiser/bruiser.cpp b/bruiser/bruiser.cpp index ad50e88..e16ffb4 100644 --- a/bruiser/bruiser.cpp +++ b/bruiser/bruiser.cpp @@ -1458,11 +1458,39 @@ class LuaWrapper return 1; } - int BrluiserLuaYolo(lua_State* __ls) + int BruiserLuaYolo(lua_State* __ls) { return 0; } + int BruiserLuaPWD(lua_State* __ls) + { + pid_t pid = fork(); + + if (pid < 0) + { + PRINT_WITH_COLOR_LB(RED, "could not fork..."); + lua_pushnumber(__ls, EXIT_FAILURE); + return 1; + } + + if (pid == 0) + { + int retval = execl("/usr/bin/pwd", "pwd", NULL); + std::cout << BLUE << "child returned " << retval << NORMAL << "\n"; + } + + if (pid > 0) + { + int status; + pid_t returned; + returned = waitpid(pid, &status, 0); + lua_pushnumber(__ls, returned); + } + + return 1; + } + #define LIST_GENERATOR(__x1) \ int List##__x1(lua_State* __ls)\ {\ @@ -1590,7 +1618,8 @@ int main(int argc, const char **argv) lua_register(LE.GetLuaState(), "getpaths", &LuaDispatch<&LuaWrapper::BruiserLuaGetPath>); lua_register(LE.GetLuaState(), "getsourcefiles", &LuaDispatch<&LuaWrapper::BruiserLuaGetSourceFiles>); lua_register(LE.GetLuaState(), "changedirectory", &LuaDispatch<&LuaWrapper::BruiserLuaChangeDirectory>); - lua_register(LE.GetLuaState(), "yolo", &LuaDispatch<&LuaWrapper::BrluiserLuaYolo>); + lua_register(LE.GetLuaState(), "yolo", &LuaDispatch<&LuaWrapper::BruiserLuaYolo>); + lua_register(LE.GetLuaState(), "pwd", &LuaDispatch<&LuaWrapper::BruiserLuaPWD>); /*its just regisering the List function from LuaWrapper with X-macros.*/ #define X(__x1, __x2) lua_register(LE.GetLuaState(), #__x1, &LuaDispatch<&LuaWrapper::List##__x1>); |