Home Man
Today's Posts

Linux & Unix Commands - Search Man Pages
Man Page or Keyword Search:
Select Section of Man Page:
Select Man Page Repository:

Linux 2.6 - man page for sysconf (linux section 3posix)

SYSCONF(P)			    POSIX Programmer's Manual			       SYSCONF(P)

       sysconf - get configurable system variables

       #include <unistd.h>

       long sysconf(int name);

       The  sysconf()  function  provides  a  method for the application to determine the current
       value of a configurable system limit or option ( variable). The implementation shall  sup-
       port all of the variables listed in the following table and may support others.

       The name argument represents the system variable to be queried.	The following table lists
       the minimal set of system variables from <limits.h> or <unistd.h> that can be returned  by
       sysconf(),  and	the  symbolic  constants defined in <unistd.h> that are the corresponding
       values used for name.

		   Variable			     Value of Name
		   {AIO_MAX}			     _SC_AIO_MAX
		   {ARG_MAX}			     _SC_ARG_MAX
		   {BC_BASE_MAX}		     _SC_BC_BASE_MAX
		   {BC_DIM_MAX} 		     _SC_BC_DIM_MAX
		   {CHILD_MAX}			     _SC_CHILD_MAX
		   Clock ticks/second		     _SC_CLK_TCK
		   {IOV_MAX}			     _SC_IOV_MAX
		   {LINE_MAX}			     _SC_LINE_MAX
		   Maximum size of getgrgid_r() and  _SC_GETGR_R_SIZE_MAX
		   getgrnam_r() data buffers
		   Maximum size of getpwuid_r() and  _SC_GETPW_R_SIZE_MAX
		   getpwnam_r() data buffers
		   {MQ_OPEN_MAX}		     _SC_MQ_OPEN_MAX
		   {MQ_PRIO_MAX}		     _SC_MQ_PRIO_MAX
		   {OPEN_MAX}			     _SC_OPEN_MAX
		   _POSIX_FSYNC 		     _SC_FSYNC
		   _POSIX_IPV6			     _SC_IPV6

		   _POSIX_SHELL 		     _SC_SHELL
		   _POSIX_SPAWN 		     _SC_SPAWN
		   _POSIX_TRACE 		     _SC_TRACE
		   _POSIX_V6_ILP32_OFF32	     _SC_V6_ILP32_OFF32
		   _POSIX_V6_LP64_OFF64 	     _SC_V6_LP64_OFF64
		   _POSIX2_C_BIND		     _SC_2_C_BIND
		   _POSIX2_C_DEV		     _SC_2_C_DEV
		   _POSIX2_FORT_DEV		     _SC_2_FORT_DEV
		   _POSIX2_FORT_RUN		     _SC_2_FORT_RUN
		   _POSIX2_PBS			     _SC_2_PBS
		   _POSIX2_SW_DEV		     _SC_2_SW_DEV
		   _POSIX2_UPE			     _SC_2_UPE
		   {PAGE_SIZE}			     _SC_PAGE_SIZE
		   {RE_DUP_MAX} 		     _SC_RE_DUP_MAX
		   {RTSIG_MAX}			     _SC_RTSIG_MAX

		   {TIMER_MAX}			     _SC_TIMER_MAX
		   _XBS5_ILP32_OFF32 (LEGACY)	     _SC_XBS5_ILP32_OFF32 (LEGACY)
		   _XBS5_LP64_OFF64 (LEGACY)	     _SC_XBS5_LP64_OFF64 (LEGACY)
		   _XOPEN_ENH_I18N		     _SC_XOPEN_ENH_I18N
		   _XOPEN_SHM			     _SC_XOPEN_SHM

       If name is an invalid value, sysconf() shall return -1  and  set  errno	to  indicate  the
       error. If the variable corresponding to name has no limit, sysconf() shall return -1 with-
       out changing the value of errno. Note that indefinite limits do not imply infinite limits;
       see <limits.h>.

       Otherwise,  sysconf()  shall  return  the  current variable value on the system. The value
       returned shall not be more restrictive than  the  corresponding	value  described  to  the
       application  when  it was compiled with the implementation's <limits.h> or <unistd.h>. The
       value shall  not  change  during  the  lifetime	of  the  calling  process,   except  that
       sysconf(_SC_OPEN_MAX)  may  return different values before and after a call to setrlimit()
       which changes the RLIMIT_NOFILE soft limit.

       The sysconf() function shall fail if:

       EINVAL The value of the name argument is invalid.

       The following sections are informative.


       As -1 is a permissible return value in a successful situation, an application  wishing  to
       check  for error situations should set errno to 0, then call sysconf(), and, if it returns
       -1, check to see if errno is non-zero.

       If the value of sysconf(_SC_2_VERSION) is not equal to the value  of  the  _POSIX2_VERSION
       symbolic  constant,  the  utilities  available via system() or popen() might not behave as
       described in the Shell and Utilities volume of IEEE Std 1003.1-2001.  This would mean that
       the  application is not running in an environment that conforms to the Shell and Utilities
       volume of IEEE Std 1003.1-2001. Some applications might be able to deal with this,  others
       might  not. However, the functions defined in this volume of IEEE Std 1003.1-2001 continue
       to operate as specified, even if sysconf(_SC_2_VERSION)	reports  that  the  utilities  no
       longer perform as specified.

       This  functionality was added in response to requirements of application developers and of
       system vendors who deal with many  international  system  configurations.  It  is  closely
       related to pathconf() and fpathconf().

       Although a conforming application can run on all systems by never demanding more resources
       than the minimum values published in this volume of IEEE Std 1003.1-2001, it is useful for
       that  application to be able to use the actual value for the quantity of a resource avail-
       able on any given system. To do this, the application makes use of the value of a symbolic
       constant in <limits.h> or <unistd.h>.

       However,  once  compiled,  the  application  must  still  be able to cope if the amount of
       resource available is increased. To that end, an application may need a means of determin-
       ing the quantity of a resource, or the presence of an option, at execution time.

       Two examples are offered:

	1. Applications  may  wish  to	act  differently  on systems with or without job control.
	   Applications vendors who wish to distribute	only  a  single  binary  package  to  all
	   instances  of  a  computer architecture would be forced to assume job control is never
	   available if it were to rely solely on the <unistd.h> value published in  this  volume
	   of IEEE Std 1003.1-2001.

	2. International  applications	vendors  occasionally  require knowledge of the number of
	   clock ticks per second. Without these facilities, they would  be  required  to  either
	   distribute their applications partially in source form or to have 50 Hz and 60 Hz ver-
	   sions for the various countries in which they operate.

       It is the knowledge that many applications are actually distributed widely  in  executable
       form  that  leads to this facility. If limited to the most restrictive values in the head-
       ers, such applications would have to be prepared to accept the most  limited  environments
       offered	by  the  smallest microcomputers. Although this is entirely portable, there was a
       consensus that they should be able to take advantage of the facilities  offered	by  large
       systems, without the restrictions associated with source and object distributions.

       During the discussions of this feature, it was pointed out that it is almost always possi-
       ble for an application to discern what a value might be at runtime by suitably testing the
       various	functions themselves. And, in any event, it could always be written to adequately
       deal with error returns from the various functions. In the end,	it  was  felt  that  this
       imposed	an  unreasonable  level  of  complication  and	sophistication on the application

       This runtime facility is not meant to provide ever-changing values that applications  have
       to  check multiple times. The values are seen as changing no more frequently than once per
       system initialization, such as by a system administrator or  operator  with  an	automatic
       configuration  program.	This volume of IEEE Std 1003.1-2001 specifies that they shall not
       change within the lifetime of the process.

       Some values apply to the system overall and others vary at the file  system  or	directory
       level. The latter are described in pathconf() .

       Note  that all values returned must be expressible as integers. String values were consid-
       ered, but the additional flexibility of this approach was rejected due to its  added  com-
       plexity of implementation and use.

       Some  values,  such  as	{PATH_MAX}, are sometimes so large that they must not be used to,
       say, allocate arrays. The sysconf() function returns a negative value to  show  that  this
       symbolic constant is not even defined in this case.

       Similar	to  pathconf(),  this  permits	the  implementation not to have a limit. When one
       resource is infinite, returning an error indicating that some  other  resource  limit  has
       been reached is conforming behavior.


       confstr()  , pathconf() , the Base Definitions volume of IEEE Std 1003.1-2001, <limits.h>,
       <unistd.h>, the Shell and Utilities volume of IEEE Std 1003.1-2001, getconf

       Portions of this text are reprinted and	reproduced  in	electronic  form  from	IEEE  Std
       1003.1,	2003  Edition,	Standard  for Information Technology -- Portable Operating System
       Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003  by
       the  Institute  of  Electrical  and  Electronics Engineers, Inc and The Open Group. In the
       event of any discrepancy between this version and the original IEEE  and  The  Open  Group
       Standard, the original IEEE and The Open Group Standard is the referee document. The orig-
       inal Standard can be obtained online at http://www.opengroup.org/unix/online.html .

IEEE/The Open Group			       2003				       SYSCONF(P)

All times are GMT -4. The time now is 10:22 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
Show Password

Not a Forum Member?
Forgot Password?