标签: linux ipc
我想将pipe的写入fd与stdout相关联。
int pfds[2]; char buf[30]; if (pipe(pfds) == -1) { perror("pipe"); exit(1); } I want to associate pfd[1] to the stdout of the process.
据我所知,我们可以使用freopen将stdout重定向到该文件。我希望得到类似的东西。
答案 0 :(得分:3)
dup2(2)可能是最简单的方法:
dup2(2)
dup2(pfds[1], STDOUT_FILENO);