Problem with Pipes => Only works first pipe

Hi!

I'm having problems with pipes... I need comunnications with childs processes and parents, but only one child can comunnicate with parent (first child), others childs can't.

A brief of code:

if(pipe(client1r)<0){
                perror("pipe");
        }
        if(pipe(client2r)<0){
                perror("pipe");
        }
        if(pipe(client3r)){
                perror("pipe");
        }
        listen(sock,5);
        while(1){
                FD_ZERO(&fds);
                FD_SET(client1r[0],&fds);
                FD_SET(client2r[0],&fds);
                FD_SET(client3r[0],&fds);
                FD_SET(sock,&fds);
                a=select(256,&fds,NULL,NULL,NULL);
                if(a>0){
                        c=0;
                        if(FD_ISSET(client1r[0],&fds)){
                                write(1,"test",12);
                        }
                        if(FD_ISSET(client3r[0],&fds)){
                                 write(1,"test",12);
                        }
                        if(FD_ISSET(client2r[0],&fds)){
                                write(1,"You Win",7);
                        }
                        if(FD_ISSET(sock,&fds)){
                                fd_client = accept(sock,0,0);
                                if(fd_client == -1){
                                        perror("accept");
                                }else{
                                        (*numlogin)=(*numlogin)+1;
                                        fill=fork();
                                        switch(fill){
                                            case 0:
                                                        if((*numlogin)==2){
                                                                close(client2r[0]);  
                                                                Client(fd_client,logins,shmid1,shmid2,shmid3,client2r[1]);
                                                        }
                                                        if((*numlogin)==1){
                                                                close(client1r[0]);
                                                               Client(fd_client,logins,shmid1,shmid2,shmid3,client1r[1]);
                                                        }
                                                        if((*numlogin)==3){
                                                                close(client3r[0]); 
                                                               Client(fd_client,logins,shmid1,shmid2,shmid3,client3r[1]);
                                                        }
                                                        break;
                                                case -1:
                                                        write(1,"Error al fork\n",14);
                                                        break;
                                                default:
                                                        close(client1r[1]);
                                                        close(client2r[1]);
                                                        close(client3r[1]);
                                                        close(fd_client); //No ho necessita
                                                        break; //PARE


Results are:

First pipe (client1r) works correctly, but others pipe (client2r and client3r) doesn't works. I don't understant why doesn't works, because others pipes are exactly the same, and then I call another function (function client) passin the value.

Any idea?

Thanks

The usual thing is to pipe, fork, the child closes the parent end and writes or reads his end, the parent closes the child end and writes or reads his end. If you want it be be stdin or stdout, you close std* and dup pipe and close pipe. If you are gutless, you use dup2. You do know pipe() makes unidirectional pipes? Once you have the fds all set up, then you select() or poll(). Pipes will say they are writable until they fill, so you may not want to include them except when you have something to write. They will say they are readable until they are empty. Why not add some logging for debug?