Bi-directional inter-process communication using two pipes
问题 I am trying to write code that forks a subprocess and communicates with it using pipes. I am using two pipes - one for writing to, and the other for reading from the standard streams of the subprocess. Here's what I have so far: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> #include <string.h> void read_move(int fd) { FILE *stream = fdopen(fd, "r"); char c; setvbuf(stream, NULL, _IONBF, BUFSIZ); while ((c = fgetc(stream)) != EOF) { putchar(c); } fclose(stream)