What exactly does fork return?

后端 未结 8 1135
时光取名叫无心
时光取名叫无心 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:09

    Fork creates a duplicate process and a new process context. When it returns a 0 value it means that a child process is running, but when it returns another value that means a parent process is running. We usually use wait statement so that a child process completes and parent process starts executing.

提交回复
热议问题