{"id":3810,"date":"2020-07-13T15:43:10","date_gmt":"2020-07-13T06:43:10","guid":{"rendered":"https:\/\/now0930.pe.kr\/wordpress\/?p=3810"},"modified":"2020-07-13T15:44:02","modified_gmt":"2020-07-13T06:44:02","slug":"pipe-%ec%98%88%ec%a0%9c-unix-network-programming-47p","status":"publish","type":"post","link":"https:\/\/now0930.pe.kr\/wordpress\/pipe-%ec%98%88%ec%a0%9c-unix-network-programming-47p\/","title":{"rendered":"pipe \uc608\uc81c. unix network programming 47p"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">pipe\ub97c \uc774\ud574\ud558\uae30 \uc804, \uc77c\ub2e8 gdb\ub97c \uc0ac\uc6a9\ud558\ub294 \ubc29\ubc95\uc744 \uc54c\uc544\uc57c \ud588\ub2e4. pipe\uac00 \uc11c\ub85c \ub2e4\ub978 \ud504\ub85c\uc138\uc2a4\ub97c \uc5f0\uacb0\ud558\ub294 \uc218\ub2e8\uc774\ub77c, gdb \uae30\ubcf8 \uc124\uc815\uc73c\ub85c\ub294 pipe\ub85c \uc5b4\ub5a4 \ub0b4\uc6a9\uc744 \ud655\uc778\ud558\uae30 \uc5b4\ub824\uc6e0\ub2e4. \uc544\ub798 \ucf54\ub4dc\ub97c \ub514\ubc84\uadf8 \ud558\uae30\ub85c \ud588\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;stdlib.h>\n#include &lt;stdio.h>\n#include &lt;unistd.h>\n#include &lt;sys\/types.h>\n#include &lt;sys\/wait.h>\n#include &lt;string.h>\n#define MAXLINE 100\n\nvoid client(int, int), server(int, int);\n\nvoid server(int readfd, int writefd){\n\tchar\tbuff[MAXLINE];\n\tint n;\n\tn = read(readfd, buff, MAXLINE);\n\tprintf(\"\uc11c\ubc84\uac00 \uc77d\uc740 data\ub294 %s\\n\",buff);\n}\n\nvoid client(int readfd, int writefd)\n{\n\tsize_t\tlen;\n\tssize_t\tn;\n\tchar\tbuff[MAXLINE];\n\n\t\/* 4read pathname *\/\n\tfgets(buff, MAXLINE, stdin);\n\tlen = strlen(buff);\t\t\/* fgets() guarantees null byte at end *\/\n\tif (buff[len-1] == '\\n')\n\t\tlen--;\t\t\t\t\/* delete newline from fgets() *\/\n\n\t\/* 4write pathname to IPC channel *\/\n\twrite(writefd, buff, len);\n\n\t\/* 4read from IPC, write to standard output *\/\n\twhile ( (n = read(readfd, buff, MAXLINE)) > 0)\n\t\twrite(STDOUT_FILENO, buff, n);\n}\n\n\nint main(int argc, char **argv)\n{\n\tint\t\tpipe1[2], pipe2[2];\n\tpid_t\tchildpid, childpid2;\n\tpid_t zombieFlag;\n\n\tif(\tpipe(pipe1) &lt; 0)\n\t\texit(1);\n\tif (pipe(pipe2) &lt; 0)\n\t\texit(1);\n\n\n\tprintf(\"made pipe1, pipe2\\n\");\n\t\/\/child process pipe \ub2eb\uc74c.\n\tif( (childpid = fork()) == 0) {\t\t\/\/\ub09c \uc790\uc2dd..\n\t\tclose(pipe1[1]);\n\t\tclose(pipe2[0]);\n\t\tchildpid2 = getpid();\n\n\t\tprintf(\"\uc790\uc2dd process\ub294 %d\\n\",childpid2);\n\t\tserver(pipe1[0], pipe2[1]);\n\n\t\t\/\/    pipe1 ----> server, server process \uc785\ub825\uc740 pipe1 \ucd9c\ub825.\n\t\t\/\/    pipe2 &lt;---- server, server process \ucd9c\ub825\uc740 pipi2 \uc785\ub825.\n\t\texit(0);\n\t}\n\t\/\/ \ub09c \ubd80\ubaa8.\n\tclose(pipe1[0]);\n\tclose(pipe2[1]);\n\tclient(pipe2[0], pipe1[1]);\n\n\tzombieFlag = waitpid(childpid, NULL, 0);\n\tprintf(\"\uc885\ub8cc\ub41c \uc790\uc2dd process\ub294 %d\\n\",zombieFlag);\n\t\/\/sleep(1);\n\n\texit(0);\n}\n\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\uc774 \ub0b4\uc6a9\uc744 gdb\ub85c \ud655\uc778\ud588\ub2e4. gdb\ub97c \uadf8\ub0e5 \uc2e4\ud589\ud558\uba74 detach-on-fork \uc635\uc158\uc744 on\uc73c\ub85c \uac16\ub294\ub2e4. child process\ub85c \ubd84\uae30\ud558\uba74 \uae30\uc874 \ud504\ub85c\uc138\uc2a4\ub97c \ub05d\uae4c\uc9c0 \uc2e4\ud589\ud558\ub294 \uc635\uc158\uc778 \ub4ef \ud558\ub2e4. parent \ud504\ub85c\uc138\uc2a4\ub97c \uc815\uc9c0\uc2dc\ud0a4\uace0, inferior\ub85c child \ud504\ub85c\uc138\uc2a4\ub85c \uc774\ub3d9\ud558\uc5ec \ub098\uba38\uc9c0\ub97c \uc2e4\ud589\ud558\uace0 \uc2f6\uc5c8\ub2e4. \uadf8\ub7ec\ub098 detach-on-fork off \uc5d0\uc11c\ub294 \ud504\ub85c\uc138\uc2a4\uac00 \ub05d\ub098 inferior\ub85c \uc774\ub3d9\ud574\ub3c4 \uc2e4\ud589\ud560 \uc218 \uc5c6\ub2e4. detatch-on-fork off\ub85c \uae30\uc874 \ud504\ub85c\uc138\uc2a4\ub97c \uba48\ucd94\uace0 inferior\ub85c \ub2e4\ub978 \ud504\ub85c\uc138\uc2a4\ub85c \uc62e\uaca8 \ud655\uc778\ud588\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">pi@raspberrypi:~\/Project\/cCode\/IPC $ gdb .\/a.out \nGNU gdb (Raspbian 8.2.1-2) 8.2.1\nCopyright (C) 2018 Free Software Foundation, Inc.\nLicense GPLv3+: GNU GPL version 3 or later &lt;http:\/\/gnu.org\/licenses\/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\nType \"show copying\" and \"show warranty\" for details.\nThis GDB was configured as \"arm-linux-gnueabihf\".\nType \"show configuration\" for configuration details.\nFor bug reporting instructions, please see:\n&lt;http:\/\/www.gnu.org\/software\/gdb\/bugs\/>.\nFind the GDB manual and other documentation resources online at:\n    &lt;http:\/\/www.gnu.org\/software\/gdb\/documentation\/>.\n\nFor help, type \"help\".\nType \"apropos word\" to search for commands related to \"word\"...\nReading symbols from .\/a.out...done.\n(gdb) show detach-on-fork \nWhether gdb will detach the child of a fork is on.\n(gdb) set detach-on-fork off\n(gdb) show follow-fork-mode \nDebugger response to a program call of fork or vfork is \"parent\".\n(gdb) l\n31\t\twrite(writefd, buff, len);\n32\t\n33\t\t\/* 4read from IPC, write to standard output *\/\n34\t\twhile ( (n = read(readfd, buff, MAXLINE)) > 0)\n35\t\t\twrite(STDOUT_FILENO, buff, n);\n36\t}\n37\t\n38\t\n39\tint main(int argc, char **argv)\n40\t{\n(gdb) l 2\n1\t#include &lt;stdlib.h>\n2\t#include &lt;stdio.h>\n3\t#include &lt;unistd.h>\n4\t#include &lt;sys\/types.h>\n5\t#include &lt;sys\/wait.h>\n6\t#include &lt;string.h>\n7\t#define MAXLINE 100\n8\t\n9\tvoid client(int, int), server(int, int);\n10\t\n(gdb) l\n11\tvoid server(int readfd, int writefd){\n12\t\tchar\tbuff[MAXLINE];\n13\t\tint n;\n14\t\tn = read(readfd, buff, MAXLINE);\n15\t\tprintf(\"\uc11c\ubc84\uac00 \uc77d\uc740 data\ub294 %s\\n\",buff);\n16\t}\n17\t\n18\tvoid client(int readfd, int writefd)\n19\t{\n20\t\tsize_t\tlen;\n(gdb) b 14\nBreakpoint 1 at 0x10658: file pipe.c, line 14.\n(gdb) l\n21\t\tssize_t\tn;\n22\t\tchar\tbuff[MAXLINE];\n23\t\n24\t\t\/* 4read pathname *\/\n25\t\tfgets(buff, MAXLINE, stdin);\n26\t\tlen = strlen(buff);\t\t\/* fgets() guarantees null byte at end *\/\n27\t\tif (buff[len-1] == '\\n')\n28\t\t\tlen--;\t\t\t\t\/* delete newline from fgets() *\/\n29\t\n30\t\t\/* 4write pathname to IPC channel *\/\n(gdb) b 25\nBreakpoint 2 at 0x106a4: file pipe.c, line 25.\n(gdb) r\nStarting program: \/home\/pi\/Project\/cCode\/IPC\/a.out \nmade pipe1, pipe2\n[New inferior 2 (process 2918)]\nReading symbols from \/home\/pi\/Project\/cCode\/IPC\/a.out...done.\nReading symbols from \/usr\/lib\/debug\/.build-id\/ef\/dd27c16f5283e5c53dcbd1bbc3ef136e312d1b.debug...done.\nReading symbols from \/usr\/lib\/debug\/.build-id\/fb\/85e699c11db06c7b24f74de2cdada3146442a8.debug...done.\n\nThread 1.1 \"a.out\" hit Breakpoint 2, client (readfd=5, writefd=4)\n    at pipe.c:25\n25\t\tfgets(buff, MAXLINE, stdin);\n(gdb) n\nthis is a test.\n26\t\tlen = strlen(buff);\t\t\/* fgets() guarantees null byte at end *\/\n(gdb) display buff\n1: buff = \"this is a test.\\n\\000\\000\\000\\000\\001\\000\\000\\000\\000\\360\\377\\266$\\364\\377\\276T\\332\\375\\266 \\230\\377\\266\\001\\000\\000\\000\\001\\000\\000\\000\\000\\000\\000\\000\\370\\234\\377\\266\\354j\\346\\266f\\v\\000\\000\\000\\000\\000\\000p\\b\\001\\000T\\005\\001\", '\\000' &lt;repeats 13 times>, \"D;\\376\\266\\003\\000\\000\\000\\000\\000\\000\"\n(gdb) n\n27\t\tif (buff[len-1] == '\\n')\n1: buff = \"this is a test.\\n\\000\\000\\000\\000\\001\\000\\000\\000\\000\\360\\377\\266$\\364\\377\\276T\\332\\375\\266 \\230\\377\\266\\001\\000\\000\\000\\001\\000\\000\\000\\000\\000\\000\\000\\370\\234\\377\\266\\354j\\346\\266f\\v\\000\\000\\000\\000\\000\\000p\\b\\001\\000T\\005\\001\", '\\000' &lt;repeats 13 times>, \"D;\\376\\266\\003\\000\\000\\000\\000\\000\\000\"\n(gdb) n\n28\t\t\tlen--;\t\t\t\t\/* delete newline from fgets() *\/\n1: buff = \"this is a test.\\n\\000\\000\\000\\000\\001\\000\\000\\000\\000\\360\\377\\266$\\364\\377\\276T\\332\\375\\266 \\230\\377\\266\\001\\000\\000\\000\\001\\000\\000\\000\\000\\000\\000\\000\\370\\234\\377\\266\\354j\\346\\266f\\v\\000\\000\\000\\000\\000\\000p\\b\\001\\000T\\005\\001\", '\\000' &lt;repeats 13 times>, \"D;\\376\\266\\003\\000\\000\\000\\000\\000\\000\"\n(gdb) n\n31\t\twrite(writefd, buff, len);\n1: buff = \"this is a test.\\n\\000\\000\\000\\000\\001\\000\\000\\000\\000\\360\\377\\266$\\364\\377\\276T\\332\\375\\266 \\230\\377\\266\\001\\000\\000\\000\\001\\000\\000\\000\\000\\000\\000\\000\\370\\234\\377\\266\\354j\\346\\266f\\v\\000\\000\\000\\000\\000\\000p\\b\\001\\000T\\005\\001\", '\\000' &lt;repeats 13 times>, \"D;\\376\\266\\003\\000\\000\\000\\000\\000\\000\"\n(gdb) n\n34\t\twhile ( (n = read(readfd, buff, MAXLINE)) > 0)\n1: buff = \"this is a test.\\n\\000\\000\\000\\000\\001\\000\\000\\000\\000\\360\\377\\266$\\364\\377\\276T\\332\\375\\266 \\230\\377\\266\\001\\000\\000\\000\\001\\000\\000\\000\\000\\000\\000\\000\\370\\234\\377\\266\\354j\\346\\266f\\v\\000\\000\\000\\000\\000\\000p\\b\\001\\000T\\005\\001\", '\\000' &lt;repeats 13 times>, \"D;\\376\\266\\003\\000\\000\\000\\000\\000\\000\"\n(gdb) n\n^Z\nThread 1.1 \"a.out\" received signal SIGTSTP, Stopped (user).\n0xb6f2187c in __GI___libc_read (fd=5, buf=0xbefff384, nbytes=100)\n    at ..\/sysdeps\/unix\/sysv\/linux\/read.c:26\n26\t..\/sysdeps\/unix\/sysv\/linux\/read.c: \uadf8\ub7f0 \ud30c\uc77c\uc774\ub098 \ub514\ub809\ud130\ub9ac\uac00 \uc5c6\uc2b5\ub2c8\ub2e4.\n(gdb) info inferiors\n  Num  Description       Executable        \n* 1    process 2915      \/home\/pi\/Project\/cCode\/IPC\/a.out \n  2    process 2918      \/home\/pi\/Project\/cCode\/IPC\/a.out \n(gdb) inferior 2\n[Switching to inferior 2 [process 2918] (\/home\/pi\/Project\/cCode\/IPC\/a.out)]\n[Switching to thread 2.1 (process 2918)]\n#0  arch_fork (ctid=0xb6ff9cf8) at ..\/sysdeps\/unix\/sysv\/linux\/arch-fork.h:40\n40\t..\/sysdeps\/unix\/sysv\/linux\/arch-fork.h: \uadf8\ub7f0 \ud30c\uc77c\uc774\ub098 \ub514\ub809\ud130\ub9ac\uac00 \uc5c6\uc2b5\ub2c8\ub2e4.\n(gdb) c\nContinuing.\n\nThread 2.1 \"a.out\" received signal SIGTSTP, Stopped (user).\narch_fork (ctid=0xb6ff9cf8) at ..\/sysdeps\/unix\/sysv\/linux\/arch-fork.h:40\n40\tin ..\/sysdeps\/unix\/sysv\/linux\/arch-fork.h\n(gdb) c\nContinuing.\n\nThread 2.1 \"a.out\" received signal SIGTSTP, Stopped (user).\narch_fork (ctid=0xb6ff9cf8) at ..\/sysdeps\/unix\/sysv\/linux\/arch-fork.h:40\n40\tin ..\/sysdeps\/unix\/sysv\/linux\/arch-fork.h\n(gdb) \nContinuing.\n\uc790\uc2dd process\ub294 2918\n\nThread 2.1 \"a.out\" hit Breakpoint 1, server (readfd=3, writefd=6)\n    at pipe.c:14\n14\t\tn = read(readfd, buff, MAXLINE);\n(gdb) display buff\n2: buff = \"x\\371\\377\\266,\\003\\001\\000P\\241\\377\\266\\000\\000\\000\\000\\001\\000\\000\\000\\000\\360\\377\\266$\\364\\377\\276T\\332\\375\\266\\062\\071\\061\\070\\000:\\215\\371\\001\\000\\000\\000h\\351\\377\\266p\\b\\001\\000T\\005\\001\", '\\000' &lt;repeats 14 times>, \"\\360\\377\\266$\\364\\377\\276pD\\352\\266\\354\\363\\377\\276\\000:\\215\\371\\000\\000\\000\\000\\364\\a\\001\\000\\024\\t\\001\"\n(gdb) n\n15\t\tprintf(\"\uc11c\ubc84\uac00 \uc77d\uc740 data\ub294 %s\\n\",buff);\n2: buff = \"this is a test.\\000\\001\\000\\000\\000\\000\\360\\377\\266$\\364\\377\\276T\\332\\375\\266\\062\\071\\061\\070\\000:\\215\\371\\001\\000\\000\\000h\\351\\377\\266p\\b\\001\\000T\\005\\001\", '\\000' &lt;repeats 14 times>, \"\\360\\377\\266$\\364\\377\\276pD\\352\\266\\354\\363\\377\\276\\000:\\215\\371\\000\\000\\000\\000\\364\\a\\001\\000\\024\\t\\001\"\n(gdb) n\n\uc11c\ubc84\uac00 \uc77d\uc740 data\ub294 this is a test.\n16\t}\n2: buff = \"this is a test.\\000\\001\\000\\000\\000\\000\\360\\377\\266$\\364\\377\\276T\\332\\375\\266\\062\\071\\061\\070\\000:\\215\\371\\001\\000\\000\\000h\\351\\377\\266p\\b\\001\\000T\\005\\001\", '\\000' &lt;repeats 14 times>, \"\\360\\377\\266$\\364\\377\\276pD\\352\\266\\354\\363\\377\\276\\000:\\215\\371\\000\\000\\000\\000\\364\\a\\001\\000\\024\\t\\001\"\n(gdb) n\nmain (argc=1, argv=0xbefff574) at pipe.c:63\n63\t\t\texit(0);\n(gdb) c\nContinuing.\n[Inferior 2 (process 2918) exited normally]\n(gdb) c\nContinuing.\n\nThread 1 \"a.out\" received signal SIGTSTP, Stopped (user).\n0xb6f2187c in __GI___libc_read (fd=5, buf=0xbefff384, nbytes=100)\n    at ..\/sysdeps\/unix\/sysv\/linux\/read.c:26\n26\t..\/sysdeps\/unix\/sysv\/linux\/read.c: \uadf8\ub7f0 \ud30c\uc77c\uc774\ub098 \ub514\ub809\ud130\ub9ac\uac00 \uc5c6\uc2b5\ub2c8\ub2e4.\n(gdb) c\nContinuing.\n\uc885\ub8cc\ub41c \uc790\uc2dd process\ub294 2918\n[Inferior 1 (process 2915) exited normally]\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\ub2e4\uc74c\uc740 \uc218\uc815\ub41c \ucf54\ub4dc\uc774\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#include &lt;stdlib.h>\n#include &lt;stdio.h>\n#include &lt;unistd.h>\n#include &lt;sys\/types.h>\n#include &lt;fcntl.h>\n#include &lt;sys\/wait.h>\n#include &lt;string.h>\n#include &lt;errno.h>\n#define MAXLINE 100\n\nvoid client(int, int), server(int, int);\n\nvoid server(int readfd, int writefd){\n\t\/*\n\tchar\tbuff[MAXLINE];\n\tint n;\n\tn = read(readfd, buff, MAXLINE);\n\tprintf(\"\uc11c\ubc84\uac00 \uc77d\uc740 data\ub294 %s\\n\",buff);\n\t\/\/ \uc0d8\ud50c \ud14c\uc2a4\ud2b8\uc6a9..\n\n\t*\/\n\tint fd;\n\tssize_t n;\n\tchar\tbuff[MAXLINE+1];\n\n\t\/* 4read pathname from IPC channel *\/\n\tif ( (n = read(readfd, buff, MAXLINE)) == 0)\n\t\tperror(\"end-of-file while reading pathname\");\n\tbuff[n] = '\\0';\t\t\/* null terminate pathname *\/\n\n\tif ( (fd = open(buff, O_RDONLY)) &lt; 0) {\n\t\t\t\/* 4error: must tell client *\/\n\t\tsnprintf(buff + n, sizeof(buff) - n, \": can't open, %s\\n\",\n\t\t\t\t strerror(errno));\n\t\tn = strlen(buff);\n\t\twrite(writefd, buff, n);\n\n\t} else {\n\t\t\t\/* 4open succeeded: copy file to IPC channel *\/\n\t\twhile ( (n = read(fd, buff, MAXLINE)) > 0)\n\t\t\twrite(writefd, buff, n);\n\t\tclose(fd);\n\t}\n\n}\n\nvoid client(int readfd, int writefd)\n{\n\tsize_t\tlen;\n\tssize_t\tn;\n\tchar\tbuff[MAXLINE];\n\n\t\/* 4read pathname *\/\n\tfgets(buff, MAXLINE, stdin);\n\tlen = strlen(buff);\t\t\/* fgets() guarantees null byte at end *\/\n\tif (buff[len-1] == '\\n')\n\t\tlen--;\t\t\t\t\/* delete newline from fgets() *\/\n\n\t\/* 4write pathname to IPC channel *\/\n\twrite(writefd, buff, len);\n\n\t\/* 4read from IPC, write to standard output *\/\n\twhile ( (n = read(readfd, buff, MAXLINE)) > 0)\n\t\twrite(STDOUT_FILENO, buff, n);\n}\n\n\nint main(int argc, char **argv)\n{\n\tint\t\tpipe1[2], pipe2[2];\n\tpid_t\tchildpid, childpid2;\n\tpid_t zombieFlag;\n\n\tif(\tpipe(pipe1) &lt; 0)\n\t\texit(1);\n\tif (pipe(pipe2) &lt; 0)\n\t\texit(1);\n\n\n\tprintf(\"made pipe1, pipe2\\n\");\n\t\/\/child process pipe \ub2eb\uc74c.\n\tif( (childpid = fork()) == 0) {\t\t\/\/\ub09c \uc790\uc2dd..\n\t\tclose(pipe1[1]);\n\t\tclose(pipe2[0]);\n\t\tchildpid2 = getpid();\n\n\t\tprintf(\"\uc790\uc2dd process\ub294 %d\\n\",childpid2);\n\t\tserver(pipe1[0], pipe2[1]);\n\n\t\t\/\/    pipe1 ----> server, server process \uc785\ub825\uc740 pipe1 \ucd9c\ub825.\n\t\t\/\/    pipe2 &lt;---- server, server process \ucd9c\ub825\uc740 pipi2 \uc785\ub825.\n\t\texit(0);\n\t}\n\t\/\/ \ub09c \ubd80\ubaa8.\n\tclose(pipe1[0]);\n\tclose(pipe2[1]);\n\tclient(pipe2[0], pipe1[1]);\n\n\tzombieFlag = waitpid(childpid, NULL, 0);\n\tprintf(\"\uc885\ub8cc\ub41c \uc790\uc2dd process\ub294 %d\\n\",zombieFlag);\n\t\/\/sleep(1);\n\n\texit(0);\n}<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">pi@raspberrypi:~\/Project\/cCode\/IPC $ cat test.txt \n\uc548\ub155\ud558\uc138\uc694.\nhello.\npi@raspberrypi:~\/Project\/cCode\/IPC $ .\/a.out \nmade pipe1, pipe2\n\uc790\uc2dd process\ub294 4890\nthis is a test.\nthis is a test.: can't open, No such file or directory\n\uc885\ub8cc\ub41c \uc790\uc2dd process\ub294 4890\npi@raspberrypi:~\/Project\/cCode\/IPC $ .\/a.out \nmade pipe1, pipe2\n\uc790\uc2dd process\ub294 4893\n.\/test\n.\/test: can't open, No such file or directory\n\uc885\ub8cc\ub41c \uc790\uc2dd process\ub294 4893\npi@raspberrypi:~\/Project\/cCode\/IPC $ .\/a.out \nmade pipe1, pipe2\n\uc790\uc2dd process\ub294 4895\n.\/test.txt\n\uc548\ub155\ud558\uc138\uc694.\nhello.\n\uc885\ub8cc\ub41c \uc790\uc2dd process\ub294 4895\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\uc798 \uc2e4\ud589\ub41c\ub2e4. pipe\ub97c \ub9cc\ub4e4\uace0 \ud30c\uc774\ud504 \uc591 \ub05d\uc5d0 \uc785\ub825, \ucd9c\ub825\uc73c\ub85c \uc0dd\uac01\ud588\ub294\ub370, \uc774\ub7ec\uba74 \ud5f7\uac08\ub9b0\ub2e4. \ud504\ub85c\uc138\uc2a4 \uae30\uc900\uc73c\ub85c \uc785\ub825, \ucd9c\ub825\uc744 \uc0dd\uac01\ud558\uace0 \ud30c\uc774\ud504\ub85c \uc5f0\uacb0\ud55c\ub2e4 \uc0dd\uac01\ud558\uba74 \uc27d\ub2e4.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"211\" height=\"1024\" src=\"https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2020\/07\/20200713_023512-211x1024.jpg\" alt=\"\" class=\"wp-image-3821\" srcset=\"https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2020\/07\/20200713_023512-211x1024.jpg 211w, https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2020\/07\/20200713_023512-62x300.jpg 62w, https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2020\/07\/20200713_023512-768x3725.jpg 768w, https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2020\/07\/20200713_023512-422x2048.jpg 422w, https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2020\/07\/20200713_023512-scaled.jpg 528w\" sizes=\"auto, (max-width: 211px) 100vw, 211px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\ud558&#8230; \uac00\ubcbc\uc6b4 \ub9c8\uc74c\uc73c\ub85c \ub4e4\uc5b4\uc654\ub294\ub370 IPC\ub97c \ucc45 \ud55c \uad8c\uc5d0 \uac78\uccd0 \uc124\uba85\ud558\ub124.<\/p>\n\n\n\n<figure class=\"wp-block-embed\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/www.geeksforgeeks.org\/pipe-system-call\/\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"GDB Debugging with fork() and exec()\" width=\"580\" height=\"326\" src=\"https:\/\/www.youtube.com\/embed\/IGW8-yeYRgI?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/woosunbi.tistory.com\/94\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/moss.cs.iit.edu\/cs351\/gdb-inferiors.html\n<\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>pipe\ub97c \uc774\ud574\ud558\uae30 \uc804, \uc77c\ub2e8 gdb\ub97c \uc0ac\uc6a9\ud558\ub294 \ubc29\ubc95\uc744 \uc54c\uc544\uc57c \ud588\ub2e4. pipe\uac00 \uc11c\ub85c \ub2e4\ub978 \ud504\ub85c\uc138\uc2a4\ub97c \uc5f0\uacb0\ud558\ub294 \uc218\ub2e8\uc774\ub77c, gdb \uae30\ubcf8 \uc124\uc815\uc73c\ub85c\ub294 pipe\ub85c \uc5b4\ub5a4 \ub0b4\uc6a9\uc744 \ud655\uc778\ud558\uae30 \uc5b4\ub824\uc6e0\ub2e4. \uc544\ub798 \ucf54\ub4dc\ub97c \ub514\ubc84\uadf8 \ud558\uae30\ub85c \ud588\ub2e4. \uc774 \ub0b4\uc6a9\uc744 gdb\ub85c \ud655\uc778\ud588\ub2e4. gdb\ub97c \uadf8\ub0e5 \uc2e4\ud589\ud558\uba74 detach-on-fork \uc635\uc158\uc744 on\uc73c\ub85c \uac16\ub294\ub2e4. child process\ub85c \ubd84\uae30\ud558\uba74 \uae30\uc874 \ud504\ub85c\uc138\uc2a4\ub97c \ub05d\uae4c\uc9c0 \uc2e4\ud589\ud558\ub294 \uc635\uc158\uc778 \ub4ef \ud558\ub2e4. parent \ud504\ub85c\uc138\uc2a4\ub97c \uc815\uc9c0\uc2dc\ud0a4\uace0, inferior\ub85c child \ud504\ub85c\uc138\uc2a4\ub85c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[12],"tags":[775,779,780,53,781],"class_list":["post-3810","post","type-post","status-publish","format-standard","hentry","category-12","tag-c","tag-gdb","tag-ipc","tag-linux","tag-network-program"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/3810","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/comments?post=3810"}],"version-history":[{"count":7,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/3810\/revisions"}],"predecessor-version":[{"id":3822,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/3810\/revisions\/3822"}],"wp:attachment":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/media?parent=3810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/categories?post=3810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/tags?post=3810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}