What exactly does fork return?

后端 未结 8 1155
时光取名叫无心
时光取名叫无心 2020-12-02 13:51

On success, the PID of the child process is returned in the parent’s thread of execution, and a 0 is returned in the child’s thread of e

8条回答
  •  鱼传尺愫
    2020-12-02 14:27

                                 p = fork();
                            /* assume no errors */
                            /* you now have two */
                            /* programs running */
                             --------------------
          if (p > 0) {                |            if (p == 0) {
            printf("parent\n");       |              printf("child\n");
            ...                       |              ...
    

提交回复
热议问题