sysconfのヘルプ・マニュアル
日本語 英語
sysconf --help
man sysconf
SYSCONF(3) Linux Programmer’s Manual SYSCONF(3)
名前
sysconf - 動作中に設定情報を取得する
書式
#include
long sysconf(int name);
説明
POSIX では、アプリケーションがコンパイル時や実行時に、特定のオプション
がサポートされているかや、設定可能な特定の定数や制限がどんな値かをテ ス
トすることができる。
コ ンパイル時に行うには、 と の両方もしくは一方を
インクルードし、特定のマクロの値を確認する。
実行時には、ここで説明する関数 sysconf() を使って数値を問い合わせること
が で き る 。ファイルが存在するファイルシステムに関する数値は、 fpath-
conf(3) と pathconf(3) を使って確認できる。文字列の値は confstr(3) を使
って確認できる。
こ れらの関数で取得される値は設定可能なシステム定数である。これらはプロ
セスの生存期間の間は変化しない。
オプションを確認できるように、たいていは で定 数 _POSIX_FOO
が 定義されている。定義されていないときは、実行時に問い合わせを行う必要
がある。その値が -1 に定義されているときは、そのオプションはサポート さ
れていない。 0 に定義されているときは、関連する関数やヘッダファイルが存
在するが、どの程度サポートされているかは実行時に確認しなければならな い
。 -1 でも 0 でもない値に定義されているときは、そのオプションがサポート
されている。通常は、そのオプションについて記載した POSIX の改訂年月を示
す値になっている (例えば 200112L)。 glibc では 1 が設定されていると、そ
のオプションはサポートされているが、 POSIX の改訂版がまだ発行されていな
い ことを示す。 sysconf() の引き数には _SC_FOO を指定する。オプションの
リストについては posixoptions(7) を参照のこと。
変数や制限を確認できるように、たいていは、 で定数 _FOO が 、
で _POSIX_FOO が定義されている。制限が規定されていない場合は
定数は定義されない。定数が定義されているときには、その定数は保証でき る
値 であり、実際にはもっと大きな値がサポートされていることもある。アプリ
ケーションがシステム毎に変化する値を利用したい場合には、 sysconf() を呼
び出すことで実現できる。 sysconf() の引き数には _SC_FOO を指定する。
POSIX.1 変数
変数名、その値を取得するのに使われる sysconf() のパラメータ名、簡単な説
明を以下に示す。
まず POSIX.1 互換の変数を示す。
ARG_MAX - _SC_ARG_MAX
exec(3) 関数群の引き数の最大長。 _POSIX_ARG_MAX (4096) 未満で あ
ってはならない。
CHILD_MAX - _SC_CHILD_MAX
ユ ー ザID あ た り の 同 時 に 存 在 できるプロセスの最大数。
_POSIX_CHILD_MAX (25) 未満であってはならない。
HOST_NAME_MAX - _SC_HOST_NAME_MAX
gethostname(2) で返されるホスト名の最大長。末尾の NULL バイト は
長さに含まれない。 _POSIX_HOST_NAME_MAX (255) 未満であってはなら
ない。
LOGIN_NAME_MAX - _SC_LOGIN_NAME_MAX
ログイン名の長さの最大値。末尾の NULL バイトも長さに含まれ る 。
_POSIX_LOGIN_NAME_MAX (9) 未満であってはならない。
clock ticks - _SC_CLK_TCK
1 秒あたりのクロック・ティック数。対応する変数は廃止された。この
変数は当然ながら CLK_TCK と呼ばれてい た 。 ( 注 意: マ ク ロ
CLOCKS_PER_SEC からは情報は得られない: この値は 1000000 でなけれ
ばならない)
OPEN_MAX - _SC_OPEN_MAX
一つのプロセスが同時にオープンでき る フ ァ イ ル 数 の 上 限 。
_POSIX_OPEN_MAX (20) 未満であってはならない。
PAGESIZE - _SC_PAGESIZE
バ イト単位でのページサイズ。 1 より小さくなってはならない。 (こ
の代わりに PAGE_SIZE を使うシステムもある)
RE_DUP_MAX - _SC_RE_DUP_MAX
regexec(3) と regcomp(3) で許容されてい る BRE (Basic Regular
Expression; 基 本 正 規 表 現) の 繰り返し出現回数の最大値。
_POSIX2_RE_DUP_MAX (255) 未満であってはならない。
STREAM_MAX - _SC_STREAM_MAX
一つのプロセスが同時にオープンできるストリーム数の上限。定義され
ていた場合には、この値は標準 C マクロの FOPEN_MAX と同じである。
_POSIX_STREAM_MAX (8) 未満であってはならない。
SYMLOOP_MAX
パス名の解決時に現れてもよいシンボリック・リンクの最大数。この数
を超えると、パス名解決時に ELOOP が返される。 _POSIX_SYMLOOP_MAX
(8) 未満であってはならない。
TTY_NAME_MAX - _SC_TTY_NAME_MAX
端末デバイス名の最大長。長さには末尾の NULL バイトも含まれ る 。
_POSIX_TTY_NAME_MAX (9) 未満であってはならない。
TZNAME_MAX - _SC_TZNAME_MAX
タ イ ムゾーン名として使えるバイト数の最大値。 _POSIX_TZNAME_MAX
(6) 未満であってはならない。
_POSIX_VERSION - _SC_VERSION
POSIX.1 標準が承認された年月。 YYYYMML とい う 書 式 で あ る 。
199009L という値は、1990年 9月 改訂であることを示す。
POSIX.2 変数
次 に、POSIX.2 の値を示す。これらは各ユーティリティに対する制限を指定す
る。
BC_BASE_MAX - _SC_BC_BASE_MAX
bc(1) ユーティリティで許容される obase の最大値。
BC_DIM_MAX - _SC_BC_DIM_MAX
bc(1) で許容される一つの配列中の要素数の最大値。
BC_SCALE_MAX - _SC_BC_SCALE_MAX
bc(1) で許される scale の最大値。
BC_STRING_MAX - _SC_BC_STRING_MAX
bc(1) で許容される文字列の最大長。
COLL_WEIGHTS_MAX - _SC_COLL_WEIGHTS_MAX
ロケール定義ファイル中の LC_COLLATE order キーワードのエントリに
割り当て可能な重みの最大値。
EXPR_NEST_MAX - _SC_EXPR_NEST_MAX
expr(1) において、括弧で入れ子にできる式の最大数。
LINE_MAX - _SC_LINE_MAX
ユーティリティの入力行の最大長。標準入力だけでなく、ファイルから
の入力にも適用される。長さには行の末尾の改行文字も含まれる。
RE_DUP_MAX - _SC_RE_DUP_MAX
正規表現で区間表記 (interval notation) \{m,n\} が使用されたと き
に許容される繰り返し出現回数の最大値。
POSIX2_VERSION - _SC_2_VERSION
POSIX.2 標準のバージョン。YYYYMML という書式で表記される。
POSIX2_C_DEV - _SC_2_C_DEV
POSIX.2 の C 言語開発機能がサポートされているかを示す。
POSIX2_FORT_DEV - _SC_2_FORT_DEV
POSIX.2 の FORTRAN 開発ユーティリティがサポートされているかを示
す。
POSIX2_FORT_RUN - _SC_2_FORT_RUN
POSIX.2 の FORTRAN ランタイムユーティリティがサポートされてい る
かを示す。
_POSIX2_LOCALEDEF - _SC_2_LOCALEDEF
localedef(1) を使った、POSIX.2 のロケールの作成をサポートしてい
るかを示す。
POSIX2_SW_DEV - _SC_2_SW_DEV
POSIX.2 ソフトウェア開発ユーティリティオプションがサポートされて
いるかを示す。
以下の値も存在するが、標準には含まれていない。
- _SC_PHYS_PAGES
物 理メモリのページ数。この値と _SC_PAGE_SIZE 値の積は桁溢れする
可能性があるので注意すること。
- _SC_AVPHYS_PAGES
現在利用可能な物理メモリのページ数。
- _SC_NPROCESSORS_CONF
設定されたプロセッサ数。
- _SC_NPROCESSORS_ONLN
現在オンラインの (利用可能な) プロセッサ数。
返り値
name が不正な場合、-1 が返され、 errno に EINVAL が設定される。それ以外
の場合、システムリソースの値が返り値として返され、 errno は変更されない
。問い合わせがオプションについてであれば、そのオプションが利用できる と
き は正の値が返され、利用できないときは -1 が返される。問い合わせが制限
について場合は、制限が設定されていないときに -1 が返される。
準拠
POSIX.1-2001.
バグ
ARG_MAX を使うのは難しい、なぜなら、 exec(3) の引き 数 領 域 (argument
space) のうちどれくらいがユーザの環境変数によって使われるかは分からない
からである。
いくつかの返り値はとても大きくなるだろう。これらを使ってメモリの割り 当
てを行うのは適当ではない。
関連項目
bc(1), expr(1), getconf(1), locale(1), fpathconf(3), pathconf(3),
posixoptions(7)
GNU 2007-12-12 SYSCONF(3)
SYSCONF(3) Linux Programmer’s Manual SYSCONF(3)
NAME
sysconf - Get configuration information at runtime
SYNOPSIS
#include
long sysconf(int name);
DESCRIPTION
POSIX allows an application to test at compile or run time whether cer-
tain options are supported, or what the value is of certain config-
urable constants or limits.
At compile time this is done by including and/or
and testing the value of certain macros.
At run time, one can ask for numerical values using the present func-
tion sysconf(). On can ask for numerical values that may depend on the
file system a file is in using the calls fpathconf(3) and pathconf(3).
One can ask for string values using confstr(3).
The values obtained from these functions are system configuration con-
stants. They do not change during the lifetime of a process.
For options, typically, there is a constant _POSIX_FOO that may be
defined in . If it is undefined, one should ask at run time.
If it is defined to -1, then the option is not supported. If it is
defined to 0, then relevant functions and headers exist, but one has to
ask at runtime what degree of support is available. If it is defined
to a value other than -1 or 0, then the option is supported. Usually
the value (such as 200112L) indicates the year and month of the POSIX
revision describing the option. Glibc uses the value 1 to indicate
support as long as the POSIX revision has not been published yet. The
sysconf() argument will be _SC_FOO. For a list of options, see
posixoptions(7).
For variables or limits, typically, there is a constant _FOO, maybe
defined in , or _POSIX_FOO, maybe defined in . The
constant will not be defined if the limit is unspecified. If the con-
stant is defined, it gives a guaranteed value, and a greater value
might actually be supported. If an application wants to take advantage
of values which may change between systems, a call to sysconf() can be
made. The sysconf() argument will be _SC_FOO.
POSIX.1 Variables
We give the name of the variable, the name of the sysconf() argument
used to inquire about its value, and a short description.
First, the POSIX.1 compatible values.
ARG_MAX - _SC_ARG_MAX
The maximum length of the arguments to the exec(3) family of
functions. Must not be less than _POSIX_ARG_MAX (4096).
CHILD_MAX - _SC_CHILD_MAX
The max number of simultaneous processes per user ID. Must not
be less than _POSIX_CHILD_MAX (25).
HOST_NAME_MAX - _SC_HOST_NAME_MAX
Max length of a hostname, not including the terminating null
byte, as returned by gethostname(2). Must not be less than
_POSIX_HOST_NAME_MAX (255).
LOGIN_NAME_MAX - _SC_LOGIN_NAME_MAX
Maximum length of a login name, including the terminating null
byte. Must not be less than _POSIX_LOGIN_NAME_MAX (9).
clock ticks - _SC_CLK_TCK
The number of clock ticks per second. The corresponding vari-
able is obsolete. It was of course called CLK_TCK. (Note: the
macro CLOCKS_PER_SEC does not give information: it must equal
1000000.)
OPEN_MAX - _SC_OPEN_MAX
The maximum number of files that a process can have open at any
time. Must not be less than _POSIX_OPEN_MAX (20).
PAGESIZE - _SC_PAGESIZE
Size of a page in bytes. Must not be less than 1. (Some sys-
tems use PAGE_SIZE instead.)
RE_DUP_MAX - _SC_RE_DUP_MAX
The number of repeated occurrences of a BRE permitted by
regexec(3) and regcomp(3). Must not be less than
_POSIX2_RE_DUP_MAX (255).
STREAM_MAX - _SC_STREAM_MAX
The maximum number of streams that a process can have open at
any time. If defined, it has the same value as the standard C
macro FOPEN_MAX. Must not be less than _POSIX_STREAM_MAX (8).
SYMLOOP_MAX
The maximum number of symbolic links seen in a pathname before
resolution returns ELOOP. Must not be less than _POSIX_SYM-
LOOP_MAX (8).
TTY_NAME_MAX - _SC_TTY_NAME_MAX
The maximum length of terminal device name, including the termi-
nating null byte. Must not be less than _POSIX_TTY_NAME_MAX
(9).
TZNAME_MAX - _SC_TZNAME_MAX
The maximum number of bytes in a timezone name. Must not be
less than _POSIX_TZNAME_MAX (6).
_POSIX_VERSION - _SC_VERSION
indicates the year and month the POSIX.1 standard was approved
in the format YYYYMML; the value 199009L indicates the Sept.
1990 revision.
POSIX.2 Variables
Next, the POSIX.2 values, giving limits for utilities.
BC_BASE_MAX - _SC_BC_BASE_MAX
indicates the maximum obase value accepted by the bc(1) utility.
BC_DIM_MAX - _SC_BC_DIM_MAX
indicates the maximum value of elements permitted in an array by
bc(1).
BC_SCALE_MAX - _SC_BC_SCALE_MAX
indicates the maximum scale value allowed by bc(1).
BC_STRING_MAX - _SC_BC_STRING_MAX
indicates the maximum length of a string accepted by bc(1).
COLL_WEIGHTS_MAX - _SC_COLL_WEIGHTS_MAX
indicates the maximum numbers of weights that can be assigned to
an entry of the LC_COLLATE order keyword in the locale
definition file,
EXPR_NEST_MAX - _SC_EXPR_NEST_MAX
is the maximum number of expressions which can be nested within
parentheses by expr(1).
LINE_MAX - _SC_LINE_MAX
The maximum length of a utility’s input line length, either from
standard input or from a file. This includes length for a
trailing newline.
RE_DUP_MAX - _SC_RE_DUP_MAX
The maximum number of repeated occurrences of a regular expres-
sion when the interval notation \{m,n\} is used.
POSIX2_VERSION - _SC_2_VERSION
indicates the version of the POSIX.2 standard in the format of
YYYYMML.
POSIX2_C_DEV - _SC_2_C_DEV
indicates whether the POSIX.2 C language development facilities
are supported.
POSIX2_FORT_DEV - _SC_2_FORT_DEV
indicates whether the POSIX.2 FORTRAN development utilities are
supported.
POSIX2_FORT_RUN - _SC_2_FORT_RUN
indicates whether the POSIX.2 FORTRAN runtime utilities are sup-
ported.
_POSIX2_LOCALEDEF - _SC_2_LOCALEDEF
indicates whether the POSIX.2 creation of locates via
localedef(1) is supported.
POSIX2_SW_DEV - _SC_2_SW_DEV
indicates whether the POSIX.2 software development utilities
option is supported.
These values also exist, but may not be standard.
- _SC_PHYS_PAGES
The number of pages of physical memory. Note that it is possi-
ble for the product of this value and the value of _SC_PAGE_SIZE
to overflow.
- _SC_AVPHYS_PAGES
The number of currently available pages of physical memory.
- _SC_NPROCESSORS_CONF
The number of processors configured.
- _SC_NPROCESSORS_ONLN
The number of processors currently online (available).
RETURN VALUE
If name is invalid, -1 is returned, and errno is set to EINVAL. Other-
wise, the value returned is the value of the system resource and errno
is not changed. In the case of options, a positive value is returned
if a queried option is available, and -1 if it is not. In the case of
limits, -1 means that there is no definite limit.
CONFORMING TO
POSIX.1-2001.
BUGS
It is difficult to use ARG_MAX because it is not specified how much of
the argument space for exec(3) is consumed by the user’s environment
variables.
Some returned values may be huge; they are not suitable for allocating
memory.
SEE ALSO
bc(1), expr(1), getconf(1), locale(1), fpathconf(3), pathconf(3),
posixoptions(7)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
GNU 2007-12-12 SYSCONF(3)