fork() child and parent processes

后端 未结 5 501
遥遥无期
遥遥无期 2021-02-01 10:37

I am trying to create a program that uses fork() to create a new process. The sample output should look like so:

This is the child process. My pid is 733 and my parent\'

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-01 10:53

    It is printing twice because you are calling printf twice, once in the execution of your program and once in the fork. Try taking your fork() out of the printf call.

提交回复
热议问题