Hacker News new | past | comments | ask | show | jobs | submit login

I actually installed moreutils just for errno, but I got disappointed. Here it the whole `errno -l` : http://ix.io/3VeV

Like, none of the everyday tools I use produce exit codes which correspond to these explanations.

For my scripts, I just return 1 for generic erros and 2 for bad usage. I wished I could be more specific in that and adhered to some standard.




errno codes aren't used in the exit codes of command-line tools; they're used in programmatic APIs like syscalls and libc functions.

There's no standard for process exit codes, other than "zero for success, non-zero for error".


That is not entirely true. There is sysexits.h, which tried to standardize some exit codes (originally meant for mail filters). It is used by, for instance, argp_parse().

https://sourceware.org/git/?p=glibc.git;a=blob;f=misc/sysexi...


Some programs do follow a specification (sysexits.h) where numbers 64 and higher are used for common uses, such as usage error, software error, file format error, etc.


Aldo when the oomkiller process kills another process it causes it to exit with a well known exit code: 137


That’s not an exit code; that is a fake exit code which your shell made up, since your shell has no other way to tell you that a process did not exit at all, but was killed by a signal (9, i.e. SIGKILL). This is, again, not an actual exit code, since the process did not actually exit.

See here for why you can’t use an exit status of 128+signal to fake a “killed by signal” state, either:

https://www.cons.org/cracauer/sigint.html


That’s just 128+SIGKILL (9).




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: