?? 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 + -