C programming - handling stdout and stdin using pipes
问题 I am writting a C program formed by a parent and his child (using fork). They comunicate through a pipe. Parent writes into the pipe through the standard output and child reads from the pipe through the standard input. Once they are connected, parent writes "hello world" into the pipe, and son calls exec. My code looks like this: int main(int argc, char *argv[]) { int p, a; char buf[1024]; FILE *file; size_t nread; int fd[2]; char argument[PATH_MAX]; if(pipe(fd)<0){ return 1; } p = fork();