我无法理解打印输出的顺序......
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main(void)
{
int index;
for (index = 1; index < 4; index++)
{
printf("HI\n");
fork();
}
printf("Unix System Programming\n");
exit(0);
}
很容易理解,当我只打印 unix 编程系统时,fork 工作了 2^n 次……但是当我用它打印 HI 时……我不明白为什么这个顺序?输出:
HI
HI
HI
HI
HI
Unix System Programming
HI
HI
Unix System Programming
Unix System Programming
Unix System Programming
Unix System Programming
Unix System Programming
Unix System Programming
Unix System Programming