Name

sysconf - Get configuration information at runtime

Library

libc.lib

Synopsis

  #include <unistd.h>
  long sysconf (int name);

Return values

If the call to sysconf is not successful, -1 is returned and errno is set appropriately. Otherwise, if the variable is associated with functionality that is not supported, -1 is returned and errno is not modified. Otherwise, the current variable value is returned.

Detailed description

This interface is defined by -p1003.1-88. A far more complete interface is available using sysctl.

The sysconf function provides a method for applications to determine the current value of a configurable system limit or option variable. The name argument specifies the system variable to be queried. Symbolic constants for each name value are found in the include file

  #include <unistd.h .>Shell programmers who need access to these parameters should use the getconf utility.

The available values are as follows:

_SC_ARG_MAX
  The maximum number of argument to execve.
_SC_CHILD_MAX
  The maximum number of simultaneous processes per user id.(Not supported)
_SC_CLK_TCK
  The frequency of the statistics clock in ticks per second.
_SC_IOV_MAX
  The maximum number of elements in the I/O vector used by readv, writev, recvmsg, and sendmsg.
_SC_NGROUPS_MAX
  The maximum number of supplemental groups.(Not supported)
_SC_NPROCESSORS_CONF
  The number of processors configured.(Not supported)
_SC_NPROCESSORS_ONLN
  The number of processors currently online.(Not supported)
_SC_OPEN_MAX
  The maximum number of open files per user id.(Not supported)
_SC_STREAM_MAX
  The minimum maximum number of streams that a process may have open( Not supported) at any one time.
_SC_TZNAME_MAX
  The minimum maximum number of types supported for the name of a timezone.(Not supported)
_SC_JOB_CONTROL
  Return 1 if job control is available on this system, otherwise -1.
_SC_SAVED_IDS
  Returns 1 if saved set-group and saved set-user ID is available, otherwise -1.(Not supported)
_SC_VERSION
  The version of -p1003.1 with which the system attempts to comply.(Not supported)
_SC_BC_BASE_MAX
  The maximum ibase/obase values in the bc utility.(Not supported)
_SC_BC_DIM_MAX
  The maximum array size in the bc utility.(Not supported)
_SC_BC_SCALE_MAX
  The maximum scale value in the bc utility.(Not supported)
_SC_BC_STRING_MAX
  The maximum string length in the bc utility.(Not supported)
_SC_COLL_WEIGHTS_MAX
  The maximum number of weights that can be assigned to any entry of the LC_COLLATE order keyword in the locale definition file.(Not supported)
_SC_EXPR_NEST_MAX
  The maximum number of expressions that can be nested within parenthesis by the expr utility.(Not supported)
_SC_LINE_MAX
  The maximum length in bytes of a text-processing utility’s input line.(Not supported)
_SC_RE_DUP_MAX
  The maximum number of repeated occurrences of a regular expression permitted when using interval notation.(Not supported)
_SC_2_VERSION
  The version of -p1003.2 with which the system attempts to comply.( Not supported)
_SC_2_C_BIND
  Return 1 if the system’s C-language development facilities support the C-Language Bindings Option, otherwise -1.
_SC_2_C_DEV
  Return 1 if the system supports the C-Language Development Utilities Option, otherwise -1.
_SC_2_CHAR_TERM
  Return 1 if the system supports at least one terminal type capable of all operations described in -p1003.2, otherwise -1.
_SC_2_FORT_DEV
  Return 1 if the system supports the FORTRAN Development Utilities Option, otherwise -1.
_SC_2_FORT_RUN
  Return 1 if the system supports the FORTRAN Runtime Utilities Option, otherwise -1.
_SC_2_LOCALEDEF
  Return 1 if the system supports the creation of locales, otherwise -1.
_SC_2_SW_DEV
  Return 1 if the system supports the Software Development Utilities Option, otherwise -1.
_SC_2_UPE
  Return 1 if the system supports the User Portability Utilities Option, otherwise -1.
_SC_PAGESIZE
  Returns size of a page in bytes. (Some systems use PAGE_SIZE instead.)

Note: Some of the return values may not be posix compliant.


Examples

/**
 *  Detailed description  : This test code demonstrates usage of sysconf system call , here it get max command
    line arguments that can be passed to process.
**/
#include <unistd.h>
int main()
{
  int ret = 0 ;
  ret = sysconf(_SC_ARG_MAX) ;
  if(ret < 0 )  {
    printf("Sysconf call failed \n") ;
    return -1 ;
 }
 printf("Max command line arguments = %d \n" , ret) ;
 return 0 ;
}

         

Output

max-number of commandline args supproted by system.

         


Errors

The sysconf function may fail and set errno for any of the errors specified for the library function sysctl. In addition, the following error may be reported:
[EINVAL]
  The value of the name argument is invalid.

See also

pathconf, confstr,


Bugs

The value for _SC_STREAM_MAX is a minimum maximum, and required to be the same as ANSI C’s FOPEN_MAX, so the returned value is a ridiculously small and misleading number.

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top