IPC Pipe sample code

This commit is contained in:
2025-09-25 16:06:09 +09:00
parent b6991834e7
commit ae08bfe48e

26
Practice_06/ipcPipe.c Normal file
View File

@@ -0,0 +1,26 @@
#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;
}