More work on call tag.
This commit is contained in:
1 parent
49edce1f34
commit
632e6979ba
5 files changed
+44
-21
No files matched your search
+36
-16
@@ -13,24 +13,44 @@ namespace jet {
|
||||
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(fd[0], 1);
|
||||
if(pid != fork()) {
|
||||
argv[0] = variables["pgm"].c_str(); // TODO: Need to peel off the program name only and pass as argv[0].
|
||||
for(ix = 1; ix <= 50; ++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);
|
||||
argv[0] = variables["pgm"].c_str(); // TODO: Need to peel off the program name only and pass as argv[0].
|
||||
for(ix = 1; ix <= 50; ++ix) {
|
||||
coreutils::MString arg("arg");
|
||||
arg << ix;
|
||||
if(variableDefined(arg))
|
||||
argv[ix] = variables[arg].c_str();
|
||||
else
|
||||
break;
|
||||
}
|
||||
argv[ix] == NULL;
|
||||
pipe(fdo);
|
||||
if(pid != fork()) {
|
||||
close(fdo[0]);
|
||||
dup2(fdo[1], 1);
|
||||
if(variableDefined("input")) {
|
||||
coreutils::ZString input(variables[variables["input"]]);
|
||||
pipe(fdi);
|
||||
if(fork() == 0) {
|
||||
close(fdi[0]);
|
||||
write(fdi[1], input.getData(), input.getLength());
|
||||
close(fdi[1]);
|
||||
exit(0);
|
||||
}
|
||||
close(fdi[0]);
|
||||
dup2(fdi[0], 0);
|
||||
}
|
||||
rc = execve(variables["pgm"].c_str(), argv, NULL);
|
||||
close(fdo[1]);
|
||||
std::cout << "rc: " << rc << std::endl;
|
||||
exit(rc);
|
||||
}
|
||||
close(fdo[1]);
|
||||
if(variableDefined("name"))
|
||||
global.variables[variables["name"]].read(fdo[0]);
|
||||
else
|
||||
out.read(fdo[0]);
|
||||
waitpid(pid, &status,0);
|
||||
|
||||
std::cout << "status: " << status << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user