小编leo*_*zai的帖子

为什么在我的centos中打印“ hello”三遍?

#include "csapp.h"

int main()
{
        int i;

        for (i = 0; i < 2; i++)
                fork();
        printf("hello\n");
        exit(0);
}
Run Code Online (Sandbox Code Playgroud)
/*
 *                .------------------------
 *                |
 *                |
 *                |
 *    .-----------.------------------------
 *    |
 *    |
 *    |           .------------------------
 *    |           |
 *    |           |
 *    |           |
 *    .-----------.------------------------
 *   fork        fork
 *   i=0         i=1
 */
Run Code Online (Sandbox Code Playgroud)

在过程照片中,似乎代码将打印“ hello”四次。为什么在我的centos中打印“ hello”三遍?

c fork

0
推荐指数
1
解决办法
79
查看次数

标签 统计

c ×1

fork ×1