The man pages sysctl(3) state that sysctlbyname
and the other mentioned functions return either 0 in case of success or -1 and set errno
. But the Apple Documentation (for objective C) for sysctlbyname
says the following about the the return values:
Return value
0 on success, or an error code that indicates a problem occurred. Possible error codes include EFAULT, EINVAL, ENOMEM, ENOTDIR, EISDIR, ENOENT, and EPERM.
So which is it? Or does it return something different in objective C than the C function mentioned in the man pages? But even the provided example in Apple's documentation only checks for return value -1 and then uses errno
to log the error. Seems to me that the documentation is wrong.