Skip to contentSkip to conversation

Constancy of non-standard sysconf() calls

DISCUSSION S. Gilles 1 participant 1 message Aug 19, 2015 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore

S. Gilles

author
#0 lore raw

The manual for sysconf() currently reads

The values obtained from these functions are system configuration constants. They do not change during the lifetime of a process.

This is not strictly true for some of the non-standard options. In particular, sysconf(_SC_NPROCESSORS_ONLN) may change on a hotpluggable machine during the life of a program (at least with glibc 2.21). For example:

#include <stdio.h>
#include <unistd.h>

int
main(void)

{
        while (1) {
                printf("%ld\n", sysconf(_SC_NPROCESSORS_ONLN));
                sleep(1);
        }

        return 0;
}

may print different things over time if, during the running life of the program, I twiddle with /sys/devices/system/cpu/cpu*/online .

This value is noted as possibly non-standard, and is certainly not standard in the wild (e.g. musl-libc treats _SC_NPROCESSORS_ONLN as _SC_NPROCESSORS_CONF, while under glibc the two arguments can give different results), but the current wording of the page seems to cover even non-standard values. Perhaps the unchangingness could be qualified, for example

When given standard arguments as defined below, these functions return values that are system configuration constants. They do not change during the lifetime of a process.

How does this sound?

Signature · 5 lines
S. Gilles
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html