From ae08bfe48e77eddd8f9bcf070cd9408812d53f3f Mon Sep 17 00:00:00 2001 From: foxliver Date: Thu, 25 Sep 2025 16:06:09 +0900 Subject: [PATCH] IPC Pipe sample code --- Practice_06/ipcPipe.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Practice_06/ipcPipe.c diff --git a/Practice_06/ipcPipe.c b/Practice_06/ipcPipe.c new file mode 100644 index 0000000..0497a63 --- /dev/null +++ b/Practice_06/ipcPipe.c @@ -0,0 +1,26 @@ +#include +#include +#include + +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; +} \ No newline at end of file