ramu said:
Hi All,
We know that a c function never returns more than one value.
Then how come the fork() function returns two values? How it is
implemented?
Regards
Your question is off-topic here as fork() is POSIX.1.
I will give you an answer but you should also ask
the question in a UNIX group to get a validation:
If you read the manual for fork (man fork) you'll see that
fork() causes the creation of a new process. Read the rest
of the stuff and when you get to RETURN VALUES it says:
Upon successful completion fork() returns a value of 0 to the
child process and returns the process ID of the child process
to the parent process. So fork creates a clone of your project
and returns with the ID to the calling process. The cloned
fork call in the child returns 0. Both processes continue after
the call like the call was executed on both processes. The
function returns only one value for every return.
Again, check the appropriate group because you may be able
to get a clearer explanation and it's likely to be more
correct than mine.