Added call tag. Updated read tag.
This commit is contained in:
1 parent
d10ed783fa
commit
8443495675
8 files changed
+83
-8
No files matched your search
+37
@@ -0,0 +1,37 @@
|
||||
#include "__call.h"
|
||||
#include "Exception.h"
|
||||
#include "MString.h"
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
namespace jet {
|
||||
|
||||
__call::__call(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) {
|
||||
if(hasContainer)
|
||||
throw coreutils::Exception("call cannot have a container.");
|
||||
if(!variableDefined(coreutils::ZString("pgm")))
|
||||
throw coreutils::Exception("pgm keyword must be specified.");
|
||||
pipe[fd]; // TODO: Get these pipes to work with name and input keywords.
|
||||
dup2(0);
|
||||
if(pid != fork()) {
|
||||
argv[0] = variables["pgm"]; // TODO: Need to peel off the program name only and pass as argv[0].
|
||||
for(ix = 1; ix <= ARG_MAX; ++ix) {
|
||||
coreutils::MString arg("arg");
|
||||
arg << ix;
|
||||
if(variableDefined(arg))
|
||||
argv[ix] = variables[arg].c_str();
|
||||
else
|
||||
break;
|
||||
}
|
||||
argv[ix] == NULL;
|
||||
execve(variables["pgm"].c_str(), argv, NULL);
|
||||
exit(-1);
|
||||
}
|
||||
waitpid(&status);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user