library: dont use vm_min_free on non-Linux systems

For a specific slice of kernel versions we can get a better
estimate of the available memory before the "real" available
figure appears around kernel 3.2

However, that middle method requires a /proc/sys/vm directory.
FreeBSD 9.x used to emulate a < 2.6.27 kernel procfs meaning
it never tried the middle method. FreeBSD 10.x emulates something
more modern, but without the available figure and without a
/proc/sys/vm, so the library falls into a hole.

Hurd may to one day have this bug so we'll exclude him as well
as its triggered by whatever number appears in
/proc/sys/kernel/osrelease

References:
 commit 3f3b1a59ad
 https://bugs.debian.org/831396
This commit is contained in:
Craig Small 2016-07-17 09:06:24 +10:00
parent 63f8c16fa4
commit 2e4959bab8
2 changed files with 5 additions and 0 deletions

1
NEWS
View File

@ -1,6 +1,7 @@
procps-ng-NEXT
----------------
* watch: define HOST_NAME_MAX where not defined Debian #830734
* library: dont use vm_min_free on non Linux Debian #831396
procps-ng-3.3.12
----------------

View File

@ -719,6 +719,7 @@ nextline:
/* zero? might need fallback for 2.6.27 <= kernel <? 3.14 */
if (!kb_main_available) {
#ifdef __linux__
if (linux_version_code < LINUX_VERSION(2, 6, 27))
kb_main_available = kb_main_free;
else {
@ -734,6 +735,9 @@ nextline:
if (mem_available < 0) mem_available = 0;
kb_main_available = (unsigned long)mem_available;
}
#else
kb_main_available = kb_main_free;
#endif /* linux */
}
}