views:

92

answers:

5

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.

+7  A: 

I think the only standard is 0 for success and non-zero for failure. And that's more of a convention than a standard.

Douglas Leeder
+1. Beat me to it.
David Stratton
+2  A: 

There is no such thing as a standard set of exit codes that applications should conform to.

http://forums11.itrc.hp.com/service/forums/questionanswer.do?admit=109447626+1255018889157+28353475&threadId=1029356

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.

David Stratton
thanks. This is what I was assuming, jsut wanted to make sure I wasn't missing anything...
MikeD
+1  A: 

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.

Will Eddins
+1  A: 

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.

Laurence Gonsalves
A: 

Implement what you'll use. Anything else is superfluous.

Stephane Grenier