23,120
社区成员
发帖
与我相关
我的任务
分享
int pid;
int pfd[2];
iRtn = pipe(pfd);
//creat sub process 1 do your business
pid = fork()
if pid == 0
{
close(pfd[1]);
dup2(pfd[0], 0);
# now this sub process's standard output was redirect to pfd[0]
exit(0)
}
//create sub process 2 do dump sub process 1 standard output to file 1 and file 2
pid = fork()
if pid == 0
{
close(pfd[0]);
//read from pfd[1] and append the content readed from pfd[1] to file1 and file2
exit(0)
}