When a main() function returns the value, the process is terminated.
When you call an exit() function, which is available in the stdlib.h library, to terminate a process.
When you call the _Exit() or _exit() functions available in stdlib.h and unistd.h, respectively, to terminate a process.
When you call pthread_exit to terminate the process.
When you call an abort() function to abnormally terminate the process.
When the programmer raises a signal, the process is terminated abnormally if the custom handler or built-in signal handler is not available. But you can handle the signals with a custom/built-in signal handler.
Thread cancellation requests are also responsible for process termination. A thread cancellation request is the termination of a thread before its job is done in the process.
Any I/O failure/interrupt leads to process termination. For example, if the process is waiting for input from a scanner but the scanner is not working, this leads to process termination. If there is any custom exception handler code available, this situation is handled easily without the process being terminated.
In some situations, a child process is terminated because of a parent process request.
A process is terminated when it is trying to access unallocated or unauthorized resources. For example, when a process tries to execute a program that doesn’t have execution permissions, it leads to process termination. When a program tries to access memory that it does not own, it leads to process termination.