#define MSGSIZE 25
main()
{
int pfd[2],pid;
static charmsgsend[MSGSIZE+1]=”Hi!Kid.n”;
static charmsgrev[MSGSIZE+1];
if(pipe(pfd)==-1)
{
perror(“pipe”);
exit(1);
}
if((pid=fork())==0)
{
puts(“beforeread”);
read(pfd[0],msgrev,strlen(msgsend)+1);
puts(“readcompletely”);
puts(msgrev);
}
else
{
puts(“Parentsleeping......”);
sleep(2);
puts(“Parentwakeup......”);
write(pfd[1],msgsend,strlen(msgsend)+1);
}
exit(0);
}
最后
以上就是慈祥橘子最近收集整理的关于linux实验四---管道的全部内容,更多相关linux实验四---管道内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复