linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "S. Gilles" <sgilles-X9d1TDB9xtu3n+kRt3O4EA@public.gmane.org>
To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cc: linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Constancy of non-standard sysconf() calls
Date: Wed, 19 Aug 2015 00:22:32 -0400	[thread overview]
Message-ID: <20150819042232.GY5334@number18> (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?

-- 
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

                 reply	other threads:[~2015-08-19  4:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150819042232.GY5334@number18 \
    --to=sgilles-x9d1tdb9xtu3n+krt3o4ea@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).