The error codes perror relies on don't come from "libc." They come from
the kernel. The values only make sense if the error is the result of a
system call.
-----Original Message-----
This only works if you call libc directly, or if the code you call
(including your own) reuses libc errno codes. If you deal with libfoo,
libfoo has its own error codes, and has no perror-like function, you must
write your own :(
.