#include "__call.h" #include "Exception.h" #include "MString.h" #include #include #include #include #include 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); } }