revin cu "ramasitele" codului care INCA mai dau outputul de mai sus (ma gandesc ca asa se va crea o imagine mai clara) :<br><br>int main()<br>{<br> <br> do<br> {<br> cout << "\n> ";
<br> string line;<br> getline(cin, line);<br> <br> command_t* root = NULL;<br> if (parse_line(line.c_str(), &root))<br> {<br> if (root != NULL)<br> {<br>
pid_t new_pid;<br> int pipeDescriptors[2];<br> pipe(pipeDescriptors);<br> //root->aux = pipeDescriptors+1;<br> //cout << getpid() << endl;
<br><br> /*switch (new_pid = fork())<br> {<br> case -1: //fork failed<br> exit(-1);<br> case 0://copilul<br> close(pipeDescriptors[0]);
<br> //cout << getpid() << endl;<br> execute_command(root);<br> exit(-1);<br> default:<br> {*/
<br> int status,response;<br> close(pipeDescriptors[1]);<br><br> //do<br> //{<br> // response = wait(&status);
<br><br> //dupa ce se termina fiecare proces verific daca a trimis o comanda interna pe pipe<br> //apelez cu forwardingPipeDesc = 0 deoarece sunt in procesul primar
<br> //si nu mai trimit nicaieri mai sus comanda<br> //processInternalCommandsFromPipe(pipeDescriptors[0],0);<br> //}<br> //while (response != -1);
<br> //dupa ce am citit datele trimise de procesul copil, nu mai am nevoie de capatul de citire si il inchid<br> close(pipeDescriptors[0]);<br><br> free_parse_memory();
<br> close(pipeDescriptors[0]);<br> exit(0);<br> /*}<br> <br> }*/<br> <br> }<br> }
<br><br> free_parse_memory();<br> }<br> while (1);<br> <br> return EXIT_SUCCESS;<br>}<br><br>