Program exit status conventions

user877329 picture user877329 · Aug 15, 2013 · Viewed 9k times · Source

What is conventional return values for applications in Windows and GNU/Linux respectivly. 0 means success. But what should be used on user-requested abort. When I abort on Windows, it returns 3, but this value is not in the list of system error codes if it is not an ERROR_PATH_NOT_FOUND. GNU binutils uses 1. From a user perspective, returning GetLastError or errno would be good since they are documented, but is these only seems to cover lower level status codes. I am looking for a value that represents "Application terminated unsuccessfully"

The reason I wounder is that I want to

exit(errcode)

from a signal handler that catches some Access Violation/SIGSEGV (i.e programming errors) after printing a message about where it occured. Then the error code should be destiguishable from user input errors.

Answer

drgn picture drgn · Aug 15, 2013

This might help, http://tldp.org/LDP/abs/html/exitcodes.html those are the standard exit code. The rest of them I think are program dependant. basically you need to verify the documentation of the specific software you are looking for. As @devnull said, any exit code that is not zero implies an unsuccessful termination