Contradictory documentation for sysctl functions

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.

Answered by ForumsContributor in
Accepted Answer

First up, the document you referenced is for the kernel version of sysctlbyname, whereas the man page is for the user space version. You should not assume that similarly-named KPIs and APIs have exactly the same interface.

Having said that, in this case they do (-: and the interface defined in the man page is correct. Please file a bug against the KPI documentation.


Oh, one further clarification about that first point. For user space BSD-level APIs the man pages are Apple’s official documentation. It would be nice if those man pages were available as part of the standard documentation on the developer web site but that’s currently not the case (r. 16512537)-:

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Contradictory documentation for sysctl functions
 
 
Q