📄 pipe.c
字号:
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(void)
{int fd[2];
pid_t x;
char S[100];
pipe(fd);
x = fork();
if (x == 0)
{ printf("Child Process<%d> Send Hello to Father Process!\n", getpid());
sleep(1);
sprintf(S, "Hello from Child Process!");
close(fd[0]);
write(fd[1], S, 50);
close(fd[1]);
sleep(1);
}
else
{//wait(0);
close(fd[1]);
read(fd[0], S, 50);
close(fd[0]);
printf("Father Process<%d> receive the message : ** %s **\n", getpid(), S);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -