I want to create multiple processes from one master process. I know I want to use a function from the exec family, but it does not seem to be preforming in the way I intended it to. It seems that exec() is a blocking call, or maybe I am just using it wrong. Anyway, on to the code:
const char* ROUTERLOCATION = "../../router";
int main(int argc, char** argv) {
manager manager;
vector<string> instructions = manager.readFile(argv[1]);
...
//file gives me the number of proceses i want to spawn and that value goes in
//rCount
for(int i = 0; i < rCount; i++){
cout << "creating:" << i << endl;
execl(ROUTERLOCATION, "",NULL);
}
}
The output I see is:
creating:0
HI!!!
And then everything exits gracefully. Can I not spawn more than one process using execl()
?
Also, I would like to communicate with each of these processes, so I don't want to be blocking while these processes are running.