diff options
Diffstat (limited to 'lib/LuaTask.cc')
-rw-r--r-- | lib/LuaTask.cc | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/lib/LuaTask.cc b/lib/LuaTask.cc index 4d9cca6..a0fe0c3 100644 --- a/lib/LuaTask.cc +++ b/lib/LuaTask.cc @@ -1,8 +1,12 @@ #include <LuaTask.h> #include <LuaHandle.h> +#include <TaskMan.h> #ifndef LUATASK_OMIT_HTTPCLIENT #include <HttpClient.h> #endif +#ifndef LUATASK_OMIT_COMMAND +#include <CopyJob.h> +#endif LuaTask * LuaTask::top = 0; @@ -60,7 +64,11 @@ int LuaTask::Do() throw (GeneralException) { #ifndef LUATASK_OMIT_COMMAND if (task == "Command") { - nargs = 0; + delete p; + printm(M_INFO, "Got there (end of command - should)\n"); + LuaBuffer o(b); + o.pushdestruct(L); + nargs = 1; } #endif @@ -90,7 +98,7 @@ int LuaTask::Do() throw (GeneralException) { #endif #ifndef LUATASK_OMIT_COMMAND } else if (task == "Command") { - pid_t p; + pid_t pid; int i; char * cmd; @@ -105,14 +113,20 @@ int LuaTask::Do() throw (GeneralException) { } args[L->gettop() - 1] = 0; - if (!(p = fork())) { + b = new Buffer(true); + p = new InPipe(); + + if (!(pid = fork())) { + p->Hook(); execvp(cmd, args); } - WaitFor(p); + c = new CopyJob(p, b); for (i = 3; i <= L->gettop(); i++) { - free(args[i - 3]); + free(args[i - 2]); } free(cmd); + current = 3; + WaitFor(pid); Suspend(TASK_ON_HOLD); #endif } else { @@ -122,6 +136,15 @@ int LuaTask::Do() throw (GeneralException) { } else { return TASK_DONE; } + break; +#ifndef LUATASK_OMIT_COMMAND + case 3: + printm(M_INFO, "Got here (case 3), and event = %i\n", TaskMan::Event()); + current = 2; + WaitFor(c); + p->HalfClose(); + return TASK_ON_HOLD; +#endif } return TASK_ON_HOLD; |