Code
/* Program A */
int main()
{
int i = 3;
int pid;
while(i > 0) {
pid = fork();
if (pid > 0) {
exit(0);
} else {
i--;
}
}
}
Code
/* Program B */
int main()
{
int i = 3;
int pid;
while(i > 0) {
pid = fork();
if (pid > 0) {
i--;
exit(0);
} else {
// nothing
}
}
}
For each say how many new processes it creates (not counting the initial process).
i got 3 for A and unending for B , is that correct?