26 lines
435 B
C
26 lines
435 B
C
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
|
|
int main(){
|
|
pid_t pid;
|
|
int fd[2], n;
|
|
char buf[10];
|
|
|
|
pipe(fd);
|
|
pid = fork();
|
|
|
|
if(pid == 0){
|
|
close(fd[0]);
|
|
write(fd[1], "FOXLIVER", 9);
|
|
close(fd[1]);
|
|
}else{
|
|
close(fd[1]);
|
|
n = read(fd[0], buf, 10);
|
|
buf[n] = '\0';
|
|
printf("Parent receive : %s\n", buf);
|
|
close(fd[0]);
|
|
}
|
|
|
|
return 0;
|
|
} |