Constancy of non-standard sysconf() calls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

-- 
S. Gilles
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux