4 ms·
Its a shame errno is even needed, and is one of my pet peeves about linux. On linux, errno.h is fragmented across several places because errnos are different o
by drewg123 5y ago
Its a shame errno is even needed, and is one of my pet peeves about linux.
On linux, errno.h is fragmented across several places because errnos are different on different architectures. I think this started because when Linus did the initial alpha port, he bootstrapped Linux using a DEC OSF/1 userland, which meant that he had to use the DEC OSF/1 BSD-derived values of errno rather than the native linux ones so that they would run properly. I'm not sure why this wasn't cleaned up before it made it into the linux API on alpha.
At least on FreeBSD, determining what errno means what is just a grep in /usr/include/sys/errno.h. And it uses different errnos for different ABIs (eg, linux binaries get their normal errnos, not the FreeBSD ones).
- tedunangst 5y agoFreebsd doesn't have man errno??
- drewg123 5y agoIt does, but its easier to grep for the number in a errno.h
- bakul 5y agoI’ve used this for years: errno () { grep \\\<$*\\\> /usr/include/sys/errno.h } There will be a false positive now & then but this is good enough.