⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 library_27.html

📁 Linux程序员的工作手册
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!-- This HTML file has been created by texi2html 1.27     from library.texinfo on 3 March 1994 --><TITLE>The GNU C Library - System Configuration Parameters</TITLE><P>Go to the <A HREF="library_26.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_26.html">previous</A>, <A HREF="library_28.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_28.html">next</A> section.<P><H1><A NAME="SEC454" HREF="library_toc.html#SEC454" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC454">System Configuration Parameters</A></H1><P>The functions and macros listed in this chapter give information aboutconfiguration parameters of the operating system--for example, capacitylimits, presence of optional POSIX features, and the default path forexecutable files (see section <A HREF="library_27.html#SEC469" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_27.html#SEC469">String-Valued Parameters</A>).<P><A NAME="IDX1857"></A><A NAME="IDX1858"></A><A NAME="IDX1859"></A><H2><A NAME="SEC455" HREF="library_toc.html#SEC455" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC455">General Capacity Limits</A></H2><P>The POSIX.1 and POSIX.2 standards specify a number of parameters thatdescribe capacity limitations of the system.  These limits can be fixedconstants for a given operating system, or they can vary from machine tomachine.  For example, some limit values may be configurable by thesystem administrator, either at run time or by rebuilding the kernel,and this should not require recompiling application programs.<A NAME="IDX1860"></A><P>Each of the following limit parameters has a macro that is defined in<TT>`limits.h'</TT> only if the system has a fixed, uniform limit for theparameter in question.  If the system allows different file systems orfiles to have different limits, then the macro is undefined; use<CODE>sysconf</CODE> to find out the limit that applies at a particular timeon a particular machine.  See section <A HREF="library_27.html#SEC458" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_27.html#SEC458">Using <CODE>sysconf</CODE></A>.<P>Each of these parameters also has another macro, with a name startingwith <SAMP>`_POSIX'</SAMP>, which gives the lowest value that the limit isallowed to have on <EM>any</EM> POSIX system.  See section <A HREF="library_27.html#SEC462" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_27.html#SEC462">Minimum Values for General Capacity Limits</A>.<A NAME="IDX1861"></A><P><A NAME="IDX1862"></A><U>Macro:</U> int <B>ARG_MAX</B><P>If defined, the unvarying maximum combined length of the <VAR>argv</VAR> and<VAR>environ</VAR> arguments that can be passed to the <CODE>exec</CODE> functions.<P><A NAME="IDX1863"></A><P><A NAME="IDX1864"></A><U>Macro:</U> int <B>CHILD_MAX</B><P>If defined, the unvarying maximum number of processes that can existwith the same real user ID at any one time.<P><A NAME="IDX1865"></A><P><A NAME="IDX1866"></A><U>Macro:</U> int <B>OPEN_MAX</B><P>If defined, the unvarying maximum number of files that a single processcan have open simultaneously.<P><A NAME="IDX1867"></A><U>Macro:</U> int <B>STREAM_MAX</B><P>If defined, the unvarying maximum number of streams that a singleprocess can have open simultaneously.  See section <A HREF="library_11.html#SEC120" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_11.html#SEC120">Opening Streams</A>.<P><A NAME="IDX1868"></A><P><A NAME="IDX1869"></A><U>Macro:</U> int <B>TZNAME_MAX</B><P>If defined, the unvarying maximum length of a time zone name.See section <A HREF="library_19.html#SEC319" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_19.html#SEC319">Functions and Variables for Time Zones</A>.<P>These limit macros are always defined in <TT>`limits.h'</TT>.<A NAME="IDX1870"></A><P><A NAME="IDX1871"></A><U>Macro:</U> int <B>NGROUPS_MAX</B><P>The maximum number of supplementary group IDs that one process can have.<P>The value of this macro is actually a lower bound for the maximum.  Thatis, you can count on being able to have that many supplementary groupIDs, but a particular machine might let you have even more.  You can use<CODE>sysconf</CODE> to see whether a particular machine will let you havemore (see section <A HREF="library_27.html#SEC458" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_27.html#SEC458">Using <CODE>sysconf</CODE></A>).<P><A NAME="IDX1872"></A><U>Macro:</U> int <B>SSIZE_MAX</B><P>The largest value that can fit in an object of type <CODE>ssize_t</CODE>.Effectively, this is the limit on the number of bytes that can be reador written in a single operation.<P>This macro is defined in all POSIX systems because this limit is neverconfigurable.<P><A NAME="IDX1873"></A><U>Macro:</U> int <B>RE_DUP_MAX</B><P>The largest number of repetitions you are guaranteed is allowed in theconstruct <SAMP>`\{<VAR>min</VAR>,<VAR>max</VAR>\}'</SAMP> in a regular expression.<P>The value of this macro is actually a lower bound for the maximum.  Thatis, you can count on being able to have that many supplementary groupIDs, but a particular machine might let you have even more.  You can use<CODE>sysconf</CODE> to see whether a particular machine will let you havemore (see section <A HREF="library_27.html#SEC458" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_27.html#SEC458">Using <CODE>sysconf</CODE></A>).  And even the value that <CODE>sysconf</CODE> tellsyou is just a lower bound--larger values might work.<P>This macro is defined in all POSIX.2 systems, because POSIX.2 says itshould always be defined even if there is no specific imposed limit.<P><A NAME="IDX1874"></A><A NAME="IDX1875"></A><H2><A NAME="SEC456" HREF="library_toc.html#SEC456" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC456">Overall System Options</A></H2><P>POSIX defines certain system-specific options that not all POSIX systemssupport.  Since these options are provided in the kernel, not in thelibrary, simply using the GNU C library does not guarantee any of thesefeatures is supported; it depends on the system you are using.<A NAME="IDX1876"></A><P>You can test for the availability of a given option using the macros inthis section, together with the function <CODE>sysconf</CODE>.  The macros aredefined only if you include <TT>`unistd.h'</TT>.<P>For the following macros, if the macro is defined in <TT>`unistd.h'</TT>,then the option is supported.  Otherwise, the option may or may not besupported; use <CODE>sysconf</CODE> to find out.  See section <A HREF="library_27.html#SEC458" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_27.html#SEC458">Using <CODE>sysconf</CODE></A>.<P><A NAME="IDX1877"></A><U>Macro:</U> int <B>_POSIX_JOB_CONTROL</B><P>If this symbol is defined, it indicates that the system supports jobcontrol.  Otherwise, the implementation behaves as if all processeswithin a session belong to a single process group.  See section <A HREF="library_24.html#SEC411" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_24.html#SEC411">Job Control</A>.<P><A NAME="IDX1878"></A><U>Macro:</U> int <B>_POSIX_SAVED_IDS</B><P>If this symbol is defined, it indicates that the system remembers theeffective user and group IDs of a process before it executes anexecutable file with the set-user-ID or set-group-ID bits set, and thatexplicitly changing the effective user or group IDs back to these valuesis permitted.  If this option is not defined, then if a nonprivilegedprocess changes its effective user or group ID to the real user or groupID of the process, it can't change it back again.  See section <A HREF="library_25.html#SEC437" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_25.html#SEC437">Enabling and Disabling Setuid Access</A>.<P>For the following macros, if the macro is defined in <TT>`unistd.h'</TT>,then its value indicates whether the option is supported.  A value of<CODE>-1</CODE> means no, and any other value means yes.  If the macro is notdefined, then the option may or may not be supported; use <CODE>sysconf</CODE>to find out.  See section <A HREF="library_27.html#SEC458" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_27.html#SEC458">Using <CODE>sysconf</CODE></A>.<P><A NAME="IDX1879"></A><U>Macro:</U> int <B>_POSIX2_C_DEV</B><P>If this symbol is defined, it indicates that the system has the POSIX.2C compiler command, <CODE>c89</CODE>.  The GNU C library always defines thisas <CODE>1</CODE>, on the assumption that you would not have installed it ifyou didn't have a C compiler.<P><A NAME="IDX1880"></A><U>Macro:</U> int <B>_POSIX2_FORT_DEV</B><P>If this symbol is defined, it indicates that the system has the POSIX.2Fortran compiler command, <CODE>fort77</CODE>.  The GNU C library neverdefines this, because we don't know what the system has.<P><A NAME="IDX1881"></A><U>Macro:</U> int <B>_POSIX2_FORT_RUN</B><P>If this symbol is defined, it indicates that the system has the POSIX.2<CODE>asa</CODE> command to interpret Fortran carriage control.  The GNU Clibrary never defines this, because we don't know what the system has.<P><A NAME="IDX1882"></A><U>Macro:</U> int <B>_POSIX2_LOCALEDEF</B><P>If this symbol is defined, it indicates that the system has the POSIX.2<CODE>localedef</CODE> command.  The GNU C library never defines this, becausewe don't know what the system has.<P><A NAME="IDX1883"></A><U>Macro:</U> int <B>_POSIX2_SW_DEV</B><P>If this symbol is defined, it indicates that the system has the POSIX.2commands <CODE>ar</CODE>, <CODE>make</CODE>, and <CODE>strip</CODE>.  The GNU C libraryalways defines this as <CODE>1</CODE>, on the assumption that you had to have<CODE>ar</CODE> and <CODE>make</CODE> to install the library, and it's unlikely that<CODE>strip</CODE> would be absent when those are present.<P><H2><A NAME="SEC457" HREF="library_toc.html#SEC457" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC457">Which Version of POSIX is Supported</A></H2><P><A NAME="IDX1884"></A><U>Macro:</U> long int <B>_POSIX_VERSION</B><P>This constant represents the version of the POSIX.1 standard to whichthe implementation conforms.  For an implementation conforming to the1990 POSIX.1 standard, the value is the integer <CODE>199009L</CODE>.<P><CODE>_POSIX_VERSION</CODE> is always defined (in <TT>`unistd.h'</TT>) in anyPOSIX system.<P><STRONG>Usage Note:</STRONG> Don't try to test whether the system supports POSIXby including <TT>`unistd.h'</TT> and then checking whether<CODE>_POSIX_VERSION</CODE> is defined.  On a non-POSIX system, this willprobably fail because there is no <TT>`unistd.h'</TT>.  We do not know of<EM>any</EM> way you can reliably test at compilation time whether yourtarget system supports POSIX or whether <TT>`unistd.h'</TT> exists.<P>The GNU C compiler predefines the symbol <CODE>__POSIX__</CODE> if the targetsystem is a POSIX system.  Provided you do not use any other compilerson POSIX systems, testing <CODE>defined (__POSIX__)</CODE> will reliablydetect such systems.<P><A NAME="IDX1885"></A><U>Macro:</U> long int <B>_POSIX2_C_VERSION</B><P>This constant represents the version of the POSIX.2 standard which thelibrary and system kernel support.  We don't know what value this willbe for the first version of the POSIX.2 standard, because the value isbased on the year and month in which the standard is officially adopted.<P>The value of this symbol says nothing about the utilities installed onthe system.<P><STRONG>Usage Note:</STRONG> You can use this macro to tell whether a POSIX.1system library supports POSIX.2 as well.  Any POSIX.1 system contains<TT>`unistd.h'</TT>, so include that file and then test <CODE>defined(_POSIX2_C_VERSION)</CODE>.<P><H2><A NAME="SEC458" HREF="library_toc.html#SEC458" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC458">Using <CODE>sysconf</CODE></A></H2><P>When your system has configurable system limits, you can use the<CODE>sysconf</CODE> function to find out the value that applies to anyparticular machine.  The function and the associated <VAR>parameter</VAR>constants are declared in the header file <TT>`unistd.h'</TT>.<P><H3><A NAME="SEC459" HREF="library_toc.html#SEC459" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC459">Definition of <CODE>sysconf</CODE></A></H3><P><A NAME="IDX1886"></A><U>Function:</U> long int <B>sysconf</B> <I>(int <VAR>parameter</VAR>)</I><P>This function is used to inquire about runtime system parameters.  The<VAR>parameter</VAR> argument should be one of the <SAMP>`_SC_'</SAMP> symbols listedbelow.<P>The normal return value from <CODE>sysconf</CODE> is the value you requested.A value of <CODE>-1</CODE> is returned both if the implementation does notimpose a limit, and in case of an error.  <P>The following <CODE>errno</CODE> error conditions are defined for this function:<P><DL COMPACT><DT><CODE>EINVAL</CODE><DD>The value of the <VAR>parameter</VAR> is invalid.</DL><P><H3><A NAME="SEC460" HREF="library_toc.html#SEC460" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC460">Constants for <CODE>sysconf</CODE> Parameters</A></H3><P>Here are the symbolic constants for use as the <VAR>parameter</VAR> argumentto <CODE>sysconf</CODE>.  The values are all integer constants (morespecifically, enumeration type values).<P><DL COMPACT><DT><CODE>_SC_ARG_MAX</CODE><DD>Inquire about the parameter corresponding to <CODE>ARG_MAX</CODE>.<P><DT><CODE>_SC_CHILD_MAX</CODE><DD>Inquire about the parameter corresponding to <CODE>CHILD_MAX</CODE>.<P><DT><CODE>_SC_OPEN_MAX</CODE><DD>Inquire about the parameter corresponding to <CODE>OPEN_MAX</CODE>.<P><DT><CODE>_SC_STREAM_MAX</CODE><DD>Inquire about the parameter corresponding to <CODE>STREAM_MAX</CODE>.<P><DT><CODE>_SC_TZNAME_MAX</CODE><DD>Inquire about the parameter corresponding to <CODE>TZNAME_MAX</CODE>.<P><DT><CODE>_SC_NGROUPS_MAX</CODE><DD>Inquire about the parameter corresponding to <CODE>NGROUPS_MAX</CODE>.<P><DT><CODE>_SC_JOB_CONTROL</CODE><DD>Inquire about the parameter corresponding to <CODE>_POSIX_JOB_CONTROL</CODE>.<P><DT><CODE>_SC_SAVED_IDS</CODE><DD>Inquire about the parameter corresponding to <CODE>_POSIX_SAVED_IDS</CODE>.<P><DT><CODE>_SC_VERSION</CODE><DD>Inquire about the parameter corresponding to <CODE>_POSIX_VERSION</CODE>.<P><DT><CODE>_SC_CLK_TCK</CODE>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -