实验二

时间秒杀一切 提交于 2019-12-06 16:20:49

 

#include<sys/types.h>
#include<sys/wait.h>
#include<unistd.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
main()
{ int x,fd[2];
char buf[30],s[30];
pipe(fd);
while ((x=fork())==-1);
if (x==0)
{
close(fd[0]);
printf("Child Process!\n");
strcpy(buf,"This is an example\n");
write(fd[1],buf,30);
exit(0);
}
else{
close(fd[1]);
printf("Parent Process!\n");
read(fd[0],s,30);
printf("%s\n",s);
}
}

/******************实验二第一段代码***********************/

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!