fork

FORK(2)                    Linux Programmer's Manual                   FORK(2)



åå
       fork, vfork - åããã»ã¹ãçæãã

æ¸å¼
       #include <unistd.h>

       pid_t fork(void);
       pid_t vfork(void);

説æ
       fork ã¯è¦ªããã»ã¹ã¨PID(ããã»ã¹ ID)ï¼ããã³ PPID(親ããã»ã¹ ID)ã ããç° ãªãåãã‐
       ã»ã¹ãçæããã ãã®æï¼è³æºå©ç¨é㯠0 ã«è¨å®ããã ãã¡ã¤ã«ã‐
       ãã¯ã¨ä¿çãã¦ããã·ã°ãã«ã¯å¼ãç¶ãããªãã

       Linux ã§ã¯ï¼ fork ã æ¸ãè¾¼ã¿æã³ãã¼(copy-on-
       write)ã»ãã¼ã¸ãç¨ãã¦å®è£ãã¦ããã ãããã£ã¦ãfork ã«å¿è¦ãªæéã¨ã¡ã¢ãªã¯ 親ãã‐
       ã»ã¹ã®ãã¼ã¸ã»ãã¼ãã«ãè¤è£½ããããã¨ã åãã‐
       ã»ã¹èªèº«ã®ã¿ã¹ã¯æ§é ãä½ãã®ã«å¿è¦ãªãã®ã®ã¿ã§ããã

è¿ãå¤
       æåããå ´åã親ã®å®è¡ã¹ã¬ããã«ã¯åããã»ã¹ã® PID ãè¿ããï¼ åã®å®è¡ã¹ã¬ããã«ã¯ 0
       ãè¿ãããã 失æããå ´åã親ããã»ã¹ã« -1 ãè¿ãï¼åããã»ã¹ã¯çæãããªãã ã¾ãï¼ errno
       ãé©åã«è¨å®ãããã

ã¨ã©ã¼
       EAGAIN fork ã¯ï¼è¦ªããã»ã¹ã®ãã¼ã¸ã»ãã¼ãã«ãã³ãã¼ãåããã»ã¹ã®ã¿ã¹ã¯æ§é ã«
              çæã«å¿è¦ãªã¡ã¢ãªãå²ãå½ã¦ããã¨ãã§ããªãã£ãã

ãã°
       Linux ã§ã¯ï¼ vfork ã¯ï¼ fork ã®å¥åã«ãããªãã

æºæ
       fork 㯠SVr4, SVID, POSIX, X/OPEN, BSD 4.3 ã«æºæ ãã¦ããã

é¢é£é ç®
       clone(2), execve(2), wait(2)



Linux 1.2.9                      10 June 1995                          FORK(2)