This is only few conventions about exit codes. Let's see what some manuals say:
The GNU C Library Reference Manual
There are conventions for what sorts of status values certain programs should return.
The most common convention is simply 0 for success and 1 for failure
...
A general convention reserves status values 128 and up for special purposes
- Some non-POSIX systems use different conventions for exit status
values
- For greater portability, you can use the macros EXIT_SUCCESS and EXIT_FAILURE
for the conventional status value for success and failure.
ISO/IEC 9899:2011 (C11 standard)
If the value of status is zero or EXIT_SUCCESS, an implementation-defined form of the status successful termination is returned. If the value of status is EXIT_FAILURE, an implementation-defined form of the status unsuccessful termination is returned. Otherwise the status returned is implementation-defined.
That means if you want (and for most cases that's enough) just indicate success or failure you definitely should use EXIT_SUCCESS and EXIT_FAILURE. If you want indicate other errors, you should reinvent your own exit statuses. For example:
#define HEX_FILE_CREATE 2
#define HEX_FILE_CREATE 3
...
There is additional tips on what and how you should return:
- Warning: Don’t try to use the number of errors as the exit status. This is actually not
very useful; a parent process would generally not care how many errors occurred. Worse
than that, it does not work, because the status value is truncated to eight bits. Thus, if
the program tried to report 256 errors, the parent would receive a report of 0 errors—that
is, success
- For the same reason, it does not work to use the value of errno as the exit status—these
can exceed 255
Conclusion:
- For success always use EXIT_SUCCESS
- Your failure exit status should be beetween 1 and 127
- Don't use errno error code as exit status