Help with Mkfifo and exec

Hello guys!

I am doing a project for the university and I have to do that a process has to create several children through fork(). The father process sends a pathname to each one through exec and the children must send to the father a list with the files from each directory.

The father is waiting and the children don't send anything. I must to do the pipe with mkfifo. I am trying to send text from the children but nothing happens. This is the code that I have wroten:

struct stat buf;
 mkfifo(NOMBREFIFO, S_IRWXU);
    while (--argc>0){
        stat (argv[argc], &buf);
        if (S_ISDIR(buf.st_mode)){
            pid = fork();
            
            if (pid<0) fprintf (stderr, "error %d", errno); 
            if (pid==0) printf ("hhhhhhhhh");
            if (pid==0 && (exec=execl ("./listarordenado", argv[argc], NULL))<0) fprintf (stderr, "error %d", errno);
            if (pid>0 && wait(&status) && waitpid (pid, &status, 0)){
                printf ("ssssssssss");
                 while(TRUE) {
                      fp=open(NOMBREFIFO,O_RDONLY);
                      nbytes=read(fp,buffer,TAM_BUF-1);
                      buffer[nbytes]='\0';
                      printf("%d Cadena recibida: %s \n",i, buffer);
                      close(fp);
                      i++;
                }
                 }
         }
      } 


/////***code of listarordenado*//


for (i=0; i<50; i++){
        if ((fp=open(NOMBREFIFO,O_WRONLY))==-1)
            perror("fopen");
          else {    
                descr=write(fp,argv[1],strlen(argv[1]));
        }
         
      close(fp);
    }    

thanks,
daniel

Could you please repost this in the homework forums? you can just copy and paste.
The reason is that you have to provide school & class information.

Thank you.