Reputation: 11002
I am writing a program in C for x86 Linux. I am wanting to use my own customer exit codes to help the user with debugging problems when the program doesn't execute as expected.
As an example, suppose the program was a command line calculator and I would like to return the following exit codes and document them in the man pages;
I have seen a few pages like this one which make me think I can't return any exit code I like. Is there any official rules (BASH or Linux standard/guideline) I should be following here, apart from 0 == normal exit?
Upvotes: 1
Views: 2565
Reputation: 878
You can return any integral exit code you like. The BASH scripting guide page you reference just says it could be confusing when debugging something that returns a well-known code for some other reason.
That page also mentions /usr/include/sysexits.h
as an attempt to systematize exit codes for C programmers.
Upvotes: 5