Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
パイプの書き込み fd を標準出力に関連付けたい。
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 をファイルにリダイレクトできることは理解しています。私はこれに似たものを手に入れたいと思っていました。
dup2(2)おそらく最も簡単な方法です:
dup2(2)
dup2(pfds[1], STDOUT_FILENO);