Mam taki problem że gdy uruchamiam ponizszy kod tworzony jest plik mojeFifo jednak nie ma praw do zapisu i pokazuje się błędny deskrpytor pliku. Jezeli dodam prawo do zapisu wszystko działa poprawnie

 fifo * mojeFifo = new fifo("mojeFifo");
        int lb;
        char buffor[20];

        switch (fork()) {
        case -1:
            perror("blad tworzenia potomka");
            return 1;
            break;

        case 0:
            mojeFifo->openInWriteMode();
            execlp("ls","Mojps", "-l",NULL);
       //     exit(0);
        break;

        default ://proces macierzysty


            mojeFifo->openInReadMode();


            while ((lb = mojeFifo->readFifo(buffor) )> 0) {
                for (int i=0;i<=lb;i++)
                    if ((buffor[i] >= 'a') && (buffor[i] <='z'))
                        buffor[i] += 'A'-'a';

                write(1,buffor,lb);

            }
         cin>>tmp;
         break;
         }

a tutaj kawalek klasy

fifo::fifo(char* foo) {
    this->name = foo;
    mkfifo(this->name,0x777);
    this->MAX = 10;
    this->openedInRead = false;
    this->openedInWrite = false;
    this->declared = false;

}

void fifo::setName(char* foo)
{
    this->name = foo;
    mkfifo(this->name,0x700);
    this->MAX = 10;
    this->openedInRead = false;
    this->openedInWrite = false;
    this->declared = false;
}

void fifo::openInReadMode(void) {
    this->PDESK[1] = open(this->name,O_RDONLY);
    this->openedInRead = true;

    if (this->openedInWrite and this->openedInRead) {
        if (this->declared == false) {
            this->buff = new char[MAX+1];
            this->declared = true;
        }
    }
}

void fifo::openInWriteMode(void) {
    
   this->PDESK[0] = open(this->name,O_WRONLY);
   close(1);
   dup2(this->PDESK[0],1);

    this->openedInWrite = true;

    if (this->openedInWrite and this->openedInRead) {
        if (this->declared == false) {
            this->buff = new char[MAX+1];
            this->declared = true;
        }
    }
}

int fifo::readFifo(char *foo) {
    return read(this->PDESK[1],foo,this->MAX);

}

int fifo::writeFifo(char * foo) {

    return  write(1,foo,strlen(foo));
}

void fifo::SetMaxBuffValue(int value) {
    if (value > 0)
        this->MAX = value;
    else
        throw "Max buffer value must be grater then zero";
}

void fifo::closeStdOut(void) {
    close(1);
 
    
}