An exit code, or exit status, is a small integer number that is passed from a process to its parent when the process exits. It is the simplest way of notifying you of the result of the application execution. In Chapter 2, Unix OS Components, we briefly mentioned exit codes. We will now learn how to use them inside applications and how to interpret the exit codes of child processes.
Using exit codes
Sending exit codes
Exit codes are the way in which a process notifies its parent about its status after terminating. In order to return any exit status from the current process, there is one function that does the job in a straightforward way: os.Exit.
This function takes one argument, that is, an integer, and...