Messages in this thread | | | Date | Mon, 5 Jan 1998 12:08:16 +0100 (MET) | From | Andries.Brouwer@cwi ... | Subject | sysctl() considered harmful |
| |
A moment ago I wrote about the difference in result between using /proc and sysctl(). That seemed to indicate that nobody is using sysctl(). Now that I look a bit more, it is good that nobody uses it, because it does random things.
The names that sysctl() uses are arrays of integers. But the kernel variable addressed by such an array depends on the kernel version. Yucch!
So, any code that uses sysctl() instead of procfs must call uname() or so first, and have a built-in database with what integer names the various variables have in various kernels. And such a program will do random things next year when some kernel hacker has changed the numbers again. (And changing them was made easier by using enum's in 2.1.* instead of the #define's of 2.0.* - it seems so easy to insert something in a list.)
Maybe we should throw out sysctl(), before some author thinks that she can use it.
Andries
Ref: compare sysctl.h in 2.0.33 and 2.1.77. E.g., what value has KERN_SECURELVL? and NET_IPV4_ARP_TIMEOUT? What variable is accessed on one system by a program compiled on the other?
| |