sysconf()--Get System Configuration Variables


  Syntax
 #include <unistd.h>

 long sysconf(int name);  

  Service Program Name: QP0LLIB1

  Default Public Authority: *USE

  Threadsafe: Yes

The sysconf() function returns the value of a system configuration option. The configuration option to be obtained is specified by name.


Parameters

name
(Input) The named variable whose value is to be returned.

The value of name can be any one of the following symbols defined in the <unistd.h> header file, each corresponding to a system configuration option:



Authorities

No authorization is required.


Return Value



Error Conditions

If sysconf() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.



Error Messages

The following messages may be sent from this function:



Related Information


Example

The following example determines the value of OPEN_MAX.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

#include <stdio.h>
#include <unistd.h>
#include <errno.h>

main() {
  long result;

  errno = 0;
  puts("examining OPEN_MAX limit");
  if ((result = sysconf(_SC_OPEN_MAX)) == -1)
    if (errno == 0)
      puts("OPEN_MAX is not supported.");
    else perror("sysconf() error");
  else
    printf("OPEN_MAX is %ld\n", result);
}

Output:

examining OPEN_MAX limit
OPEN_MAX is 200


API introduced: V3R1

[ Back to top | UNIX-Type APIs | APIs by category ]