How to get child PID in C?

后端 未结 5 651
失恋的感觉
失恋的感觉 2020-12-31 03:10

I\'m creating child processes in a for-loop. Inside the child process, I can retrieve the child PID with getpid().

However, for some reas

5条回答
  •  离开以前
    2020-12-31 03:53

    If you are calling fork in the following way:

    pid = fork()
    

    Then pid is in fact your child PID. So you can print it out from the parent.

提交回复
热议问题