Process termination and exit codes
All processes have to eventually terminate, and there are many situations when process execution cannot continue, either due to errors in its own program logic or problems with the environment (such as missing files, for example). The user may also need to terminate processes by hand, either to make changes to the system, or to prevent a misbehaving process from taking up resources or interfering with the system’s functioning.
In this section, we will learn how to examine the exit code of a terminated process to guess the possible reasons for its termination, and how to communicate with processes and force their termination.
Exit codes
Most processes are short-lived – they do their job and terminate by themselves. Every process terminates with an exit code – a numeric value that indicates whether it exited normally or terminated due to an error. By convention, a zero exit code means success, and any non-zero exit code...