#include<stdio.h>
int main()
{
int x, fd[2];
char buf[30],s[30];
pipe(fd);
while((x = fork()) == -1) ;
if(x == 0)
{
sprintf(buf, "this is an example\n");
printf("child process running!\n");
write(fd[1],buf,30);
sleep(5);
exit(0);
}
else
{
wait(0);
read(fd[0],s,30);
printf("%s", s);
}
}
C语言读取pipe缓冲区内容
最新推荐文章于 2021-05-23 22:23:31 发布