There is mostly nothing found through search about calling main - so I am going to guess this question is that fundamentally 'off'.
The suggested questions provides this C# question "Calling Main() from another class" the answer there is that you don't, use a subfunction under Main() and call that; so my assumption is that the same answer applies here with fork().
void somefunction ()
{
pid_t pid;
pid = fork();
if (pid == 0) {
char *p;
char *argv[] = { (char*)spawn_count, (char*)gradiant, (char*)i, (char*)(i+spread), p };
main(5, **argv);
}
else if (pid == -1)
cout << "ERROR: can't fork" << endl;
else ; //PID == 1,
}
This compiles in g++ with "error: 'main' was not declared in this scope"
Questions:
- How is
main(argc, argv)
scoped? I can follow the process in windows withLPTSTR
. - After
fork()
, to start the child frommain()
, how is this done? - After
fork()
, where is the child, in the same function that called child, in main?