Process 创建的进程数

Process 创建的进程数,process,operating-system,Process,Operating System,在这个例子中,我想知道为什么创建了10个而不是11个进程 int main() { for (int i = 0; i <10;i++){ pid_t pid = fork(); if (pid == 0){ printf("%d",i); exit(0); } else if (pid < 0){ perror(&quo

在这个例子中,我想知道为什么创建了10个而不是11个进程

int main()
{
    for (int i = 0; i <10;i++){
        pid_t pid = fork();
        if (pid == 0){
            printf("%d",i);
            exit(0);
        }
        else if (pid < 0){
            perror("fork failed");
        }
    }
    while(wait(NULL)>0);
    printf("\n");
}
intmain()
{
对于(int i=0;i 0);
printf(“\n”);
}