So I have this function that forks N number of child processes. However it seems to be forking more than specified. Can you tell me what I\'m doing wrong? Thanks
Each child process picks up and continues the loop.
In other words, child 1 is spawned and continues with iteration #2 of loop etc.
When a process is forked, a copy of the current process is made: the resulting child process continues execution after the fork() call. That's why you must take care of the return code in your logic.