Return forking()时子进程的语句

Return statement of child process when forking()

Hello打印了多少行?

int main(){
    fn();
     printf("Hello \n");
    exit(0);
    }

  void fn(){     
    if(fork() == 0){
     fork();
      printf("Hello \n");
    }
    return;
  }

我是这个主题的新手,想了解子进程的行为方式。 我看到上面问题的答案是5.

我知道会打印 3 个语句。

我的问题:

是否return语句,return子进程到main()函数 因此子进程从那里执行?

Does the return statement, return the child processes to the main() function and hence the child processes execute from there?

是的,它们会像您的主进程一样继续执行,除非您 exit() 过早地在子进程中执行。