How to wait for each process to terminate in the following example?
问题 The program terminates after taking 4 or 5 values from scanf . But I want it to accept 8 values (totaling 8 processes) and then terminate. void main() { fork(); fork(); fork(); scanf("%d",&j); printf("The values are %d\n",j); wait(0); } 回答1: Well, the first question you have to answer to yourself is how many processes you think you have there? As you don't use the returned value from the fork(2) system call, you don't know even if you are the parent or you are the child after execution of