I'm trying to learn UNIX programming and came across a question regarding fork(). I understand that fork() creates an identical process of the currently running process, but where does it start? For example, if I have codeint main (int argc, char **argv){    int retval;    printf (This is most definitely the parent process\n);    fflush (stdout);    retval = fork ();    printf (Which process printed this?\n);    return (EXIT_SUCCESS);}The output is:This is most definitely the parent process  Which process printed this?  Which process printed this?I thought that fork() creates a same process, so I initially that that in that program, the fork() call would be recursively called forever. I guess that new process created from fork() starts after the fork() call?If I add the following code, to differentiate between a parent and child process,if (child_pid = fork ()) printf (This is the parent, child pid is %d\n, child_pid);else printf (This is the child, pid is %d\n,getpid ());after the fork() call, where does the child process begin its execution?
After fork(), where does the child begin its execution?
process;c;fork;api
The new process will be created within the fork() call, and will start by returning from it just like the parent. The return value (which you stored in retval) from fork() will be:0 in the child processThe PID of the child in the parent process-1 in the parent if there was a failure (there is no child, naturally)Your testing code works correctly; it stores the return value from fork() in child_pid and uses if to check if it's 0 or not (although it doesn't check for an error)