How to get 'sysctl vm.max_map_count', or the '/proc/sys/vm/max_map_count' using C++
I do not want to open the /proc/sys file.. Is there a http://man7.org/linux/man-pages/man2/sysctl.2.html call to get the number ?
How to get 'sysctl vm.max_map_count', or the '/proc/sys/vm/max_map_count' using C++
I do not want to open the /proc/sys file.. Is there a http://man7.org/linux/man-pages/man2/sysctl.2.html call to get the number ?
This sysctl command will return a key value pair.
sysctl -q vm.max_map_count
vm.max_map_count = xxxxxx
This sysctl command will return the same key value pair.
sysctl -e -q vm.max_map_count
vm.max_map_count = xxxxxx
This sysctl command will return the same key value pair.
sysctl -e -q vm.max_map_count
vm.max_map_count = xxxxxx
This sysctl command will return the same key value pair.
sysctl -n -e -q vm.max_map_count
xxxxxx
There is your answer. However, I would rather open /proc/sys/vm/max_map_count as a file and read the value verses executing a process from a C program. Calling sysctl in a bash script to set a variable would make more sense.
vmval=`sysctl -n -e -q vm.max_map_count`
echo $vmval
xxxxxx