linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Constancy of non-standard sysconf() calls
@ 2015-08-19  4:22 S. Gilles
  0 siblings, 0 replies; only message in thread
From: S. Gilles @ 2015-08-19  4:22 UTC (permalink / raw)
  To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA

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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-08-19  4:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-19  4:22 Constancy of non-standard sysconf() calls S. Gilles

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).