Page 1 of 1

Ending Processes

Posted: Tue May 06, 2003 7:56 am
by shad
When a thread ends, how do you tell that its done if they dont use an exit() call? I dont see how you could end it gracefully from a return..

Re:Ending Processes

Posted: Tue May 06, 2003 8:06 am
by Whatever5k
Do you mean something like following?

Code: Select all

int main(void)
{
   printf("I am a process :-)\n");
   return 0;
}
Well, the trick is: main() is not the start of a process - the *real* entry is a function often called start:

Code: Select all

_start:
  push env
  push argv
  push argc
  call main
  call exit
So the OS exits the process if it doesn't exit itself ;)