As the comments said, it is for a parent program, such as a shell or batch file, to see if the program was successful.
For example, in a shell script, using the set -e
command, the shell script will exit if any simple command returns a non-zero value.
Similarly, in a Makefile, if any compilation fails, it will exit the Makefile (Unless otherwise specified, I believe). This is used to stop compilation if a file is unable to be compiled.
Also, different exit codes can signify different errors. A code of 0
signifies success, while a non-zero value (1-255) represents failure. As said by the GNU bash manual, an exit code of 127 represents the command attempted to be executed could not be found, and 126 represents the file is not an executable.