Re: newbie question about fork/pipe/stdin/stdout



hello agin,
Thank you for replies ;-)

I changed my code to next:
.....
fcntl(pipeStdout[0], F_SETFD, fcntl(pipeStdout[0], F_GETFD) |
O_NONBLOCK);
fcntl(pipeStdin[1], F_SETFD, fcntl(pipeStdin[1], F_GETFD) |
O_NONBLOCK);
....
stream = fdopen (pipeStdin[1], "w");
streamIn = fdopen (pipeStdout[0], "r");
DEBUG ("output start");
for (unsigned int i = 0; i<msg.size();
i++) {
while(select(pipeStdout[0]+1,
&rfds, NULL, NULL, &tv)) {
DEBUG ("add input");
if (fread(&c,1,
1,streamIn)==1)
out = out+ c;
}

if(select(pipeStdin[1]+1,
NULL, &wfds, NULL, &tv)) {
if (!fputc(msg[i],stream))
{DEBUG("output failed"); break; }
DEBUG(i);
} else {
DEBUG ("send data
problem"); i--;
}
}
DEBUG("output end");
2nd "select" catch for "send data problem" when child cannot receive
more data.
In this time child should send me data back. but 1st "select" never
return value other than zero.
Where I wrong again?

Sorry for stupid questions, I never working with select/pipes before.

.