I have a program that creates a pid process with fork () and in the child makes dup2 so that what I print on the screen happens to pipeA
dup2(pipeA[1],1);
leer(archivos[j],substring);
Read me print strings of characters and with the dup2 it stores those strings in the pipeA, I want to save the information that is in the pipe in a buffer for that use:
bytes=read(pipeA[0],buffer,BUFFER_TAM);
I had already initialized my pipe with:
if (pipe(pipeA) == -1) {
perror("bad pipe1");
exit(1);
}
When copying in the linux terminal there are no errors but it stays stuck and to use the terminal again I have to use "ctrl c". The error I think is in the read because if I remove it does not stay stuck and ends but I can not use the pipe information, in case the error is here as if it is not read as read the pipe ?. I do not know if the pipe is the error, and if the pipes are read with read?