[so] Re: valgrind

Andrei Ciuca andrei.ciuca at gmail.com
Thu Nov 1 12:06:44 EET 2007


revin cu "ramasitele" codului care INCA mai dau outputul de mai sus (ma
gandesc ca asa se va crea o imagine mai clara) :

int main()
{

    do
    {
        cout << "\n> ";
        string line;
        getline(cin, line);

        command_t* root = NULL;
        if (parse_line(line.c_str(), &root))
        {
            if (root != NULL)
            {
                pid_t new_pid;
                int pipeDescriptors[2];
                pipe(pipeDescriptors);
                //root->aux = pipeDescriptors+1;
                //cout << getpid() << endl;

                /*switch (new_pid = fork())
                {
                    case -1: //fork failed
                            exit(-1);
                    case 0://copilul
                            close(pipeDescriptors[0]);
                            //cout << getpid() << endl;
                            execute_command(root);
                            exit(-1);
                    default:
                    {*/
                            int status,response;
                            close(pipeDescriptors[1]);

                            //do
                            //{
                            //    response = wait(&status);

                                //dupa ce se termina fiecare proces verific
daca a trimis o comanda interna pe pipe
                                //apelez cu forwardingPipeDesc = 0 deoarece
sunt in procesul primar
                                //si nu mai trimit nicaieri mai sus comanda

//processInternalCommandsFromPipe(pipeDescriptors[0],0);
                            //}
                            //while (response != -1);
                            //dupa ce am citit datele trimise de procesul
copil, nu mai am nevoie de capatul de citire si il inchid
                            close(pipeDescriptors[0]);

                            free_parse_memory();
                            close(pipeDescriptors[0]);
                            exit(0);
                    /*}

                }*/

            }
        }

        free_parse_memory();
    }
    while (1);

    return EXIT_SUCCESS;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cursuri.cs.pub.ro/pipermail/so/attachments/20071101/231b6627/attachment.html


More information about the so mailing list