#include<stdio.h>
#include<unistd.h>
#include<string.h>
int main()
{
int fd[2];
if (pipe(fd) < 0){
printf("pipe 失败\n");
}
char *line = NULL;
line = "hello world";
write(fd[1],line,200);
pid_t child;
child = fork();
if (child < 0){
printf("fork 失败\n");
}
else if (child == 0){
char r_line [200] = {0};
printf("子进程\n");
read(fd[0],r_line,200);
printf("line is : %s\n",r_line);
}
else{
printf("主进程\n");
}
return 0;
}
linux pipe管道
最新推荐文章于 2024-08-23 20:31:19 发布