為啥下面的代碼輸出結果是
1
1
而我推出來的結果是
1
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void create_pth(int n){
pid_t pid;
pid=fork();
if(pid<0){
printf("error");
exit(0);
}else if(pid==0){
if(n<1){
create_pth(n+1);
printf("%d\n",n);
}else{
sleep(10);
}
}else{
wait(NULL);
}
}
int main(){
create_pth(0);
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/188085.html
標籤:專題技術討論區
上一篇:aix系統郵件服務器未默認關閉vrfy,怎么手動關閉?
下一篇:win10藍屏問題
