Including the main, how many proceses does the following program create? Assume that there is no failure in process creation and proper header files have been included.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
int main()
{
int n = 2;
pid_t childpid;
int i, j;
for ( i = 0; i < n; i++ ) {
for ( j = 0; j < n; j++ ) {
if ( ( childpid = fork()) > 0 )
break;
}
wait (NULL); // wait for child
}
wait (NULL); // wait for child
return 0;
}
Is the answer to this 9? If not can someone explain their count and how I miscounted?