I am creating a child process and passing some arguments to it.
Now, the child process starts execution from the next line of code, but will I have to write another int main () separately for the child process, as below, or would it just use the already written code for int main() of the parent process?
createProcess(All required arguments);
if (pid == child_process)
{
int main ()
{
......
}
}
ENV: WinXP, VS2005
NOTE: The above code just describes the flow and may have syntax errors.
Are you confusing Windows
CreateProcesswith UNIXfork()? The two operating systems are different in the way that processes are created. With Windows you have to execute an exe file from the beginning, you can’t continue as the child process afterCreateProcessas you can withforkon UNIX. Your statement “the child process starts execution from the next line of code” is mistaken for Windows.Mind you, your code would be illegal on UNIX as well, you can’t have two functions called main, and you can’t have nested functions in C.