I'm trying to make my code play nicely with the other children on Linux systems, and I want to use exit codes that make sense to the shell.
In the specific case I'm starting with, when attempting to write to a directory that does not exist, I find two candidate codes:
#define EX_CANTCREAT 73 /* can't create (user) output file */
in sysexits.h
and (effectively):
errno.ENOENT = 2 # No such file or directory
in Python's errno
module.
Is one more appropriate than the other for a sys.exit()?
I note that Python provides errno
and there is a corresponding errno.h
but I'm not seeing anything Pythonic prebuilt for sysexits.h
...
EDIT: I was trying to determine if I should be using more specific exit codes and if so, from which set of predefined codes. The answers below give a pretty definite "No": Stick to 0 for success and 1 for failure as exit codes. Use the errno codes for stderr messages, and, for Linux at least, just stay away from sysexits.h... I think.