Home > Back-end >  More communication process pipes
More communication process pipes

Time:09-25

All bosses:

I'm writing a multi-process in pipeline communication procedures, the child process is running another program, I connect his stdin and stdout pipe reads and writes:

Dup2 (pipes1 [0], 0);
Dup2 (pipes2 [1], 1);

So in order to facilitate the parent process with his communication,


Parent, I use the fprint write to the pipe end input, then use that write the fflush FFILE *, in order to write the contents of the cache area is to make the update, then the child can read immediately read end,

Fprintf (fdopen (pipes1 [1], "w"), the content).
Int I=fflush (fdopen (pipes1 [1], "w"));
Printf (" % d \ n ", I);

But the problem is that after I fflush, I==0 shows fflush success, but the child didn't read the content, can end of the program,

Is this what to do,

CodePudding user response:

May be because the stdin and stdout caused by caching mechanism,,,, personal speculation
  • Related