Is there such thing as a standard set of application return codes? Things like returning 0 for success 1 for failure, and then so on? I have a windows server application that I am adding some return error codes and wanted to stick to standard codes in addition to the app specific ones that I will need.
views:
92answers:
5I think the only standard is 0 for success and non-zero for failure. And that's more of a convention than a standard.
There is no such thing as a standard set of exit codes that applications should conform to.
However, there are some common ones like 0 for success as you mentioned. Depending on the Operating System and tools you use, you may be able to look at the exit codes for similar apps and mimic them.
Exit codes are far from standard, and are more used for the developer to know the appropriate error that has occurred upon return of the application. The standard of 0 for success, non-zero for failure is a general trend, and is used as it lets you use the full non-zero range for all possible errors.
If your application logs errors appropriately, the exit code will likely be completely unnecessary to keep track of.
The standard status code are EXIT_SUCCESS
and EXIT_FAILURE
, defined in stdlib.h
. Pretty much everyone just uses 0 and 1 respectively, though. Some software will use different non-zero code for different types of errors.