Normal process termination

A process can terminate itself by having any thread in the process call exit().

Returning from the main thread (i.e. main()) will also terminate the process, because the code that's returned to calls exit() . This isn't true of threads other than the main thread. Returning normally from one of them causes pthread_exit() to be called, which terminates only that thread. Of course, if that thread is the last one in the process, then the process is terminated.

The value passed to exit() or returned from main() is called the exit status.