看板 Grad-ProbAsk 關於我們 聯絡資訊
#include <stdio.h> #include <unistd.h> void func(int *input) { (*input)++; } int main() { pit_t pid; int k; k=3; pid = fork(); if(pid<0) { func(&k); printf("k=%d ", k); exit(-1); } else if(pid==0) { func(&k); printf("k=%d ", k); } else { wait(NULL); func(&k); printf("k=%d ", k); exit(0); } } (A) the output k of the parent process is 4 (B) the output k of the child process is 4 (C) the last output of k is 4 請問這段程式是怎麼跑的? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.166.118.200