Ending Processes

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
shad

Ending Processes

Post 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..
Whatever5k

Re:Ending Processes

Post 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 ;)
Post Reply