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:

_SC_ARG_MAX (Not supported by the System i® product). Represents ARG_MAX, which indicates the maximum number of bytes of arguments and environment data that can be passed in an exec function.

_SC_CHILD_MAX (Not supported by the System i product). Represents CHILD_MAX, which indicates the maximum number of jobs that a real user ID (UID) can have running simultaneously.

_SC_CLK_TCK Represents the CLK_TCK macro, which indicates the number of clock ticks in a second. CLK_TCK is defined in the <time.h> header file.

_SC_JOB_CONTROL (Not supported by the System i product). Represents the _POSIX_JOB_CONTROL macro, which indicates that certain job control operations are implemented by this version of the operating system. If _POSIX_JOB_CONTROL is defined (in the <unistd.h> header file), various APIs, such as setpgid(), provide more function than when the macro is not defined.

_SC_NGROUPS_MAX Represents NGROUPS_MAX, which indicates the maximum number of supplementary group IDs (GIDs) that can be associated with a job.

_SC_OPEN_MAX Represents OPEN_MAX, which indicates the maximum number of files that a single job can have open at one time.

_SC_PAGESIZE Represents the system hardware page size. The symbol _SC_PAGESIZE is defined as the decimal value 11.

_SC_PAGE_SIZE Represents the system hardware page size. The symbol _SC_PAGE_SIZE is defined as the decimal value 12.

_SC_SAVED_IDS (Not supported by the System i product). Represents the _POSIX_SAVED_IDS macro, which indicates that this POSIX implementation has a saved set UID and a saved set GID. If the macro exists, it is defined in the <unistd.h> header file. This symbol affects the behavior of such functions as setuid() and setgid().

_SC_STREAM_MAX Represents the STREAM_MAX macro, which indicates the maximum number of streams that a job can have open at one time. The macro is defined in the <limits.h> header file.

_SC_TZNAME_MAX (Not supported by the System i product). Represents the TZNAME_MAX macro, which indicates the maximum length of the name of a time zone. If the macro exists, it is defined in the <limits.h> header file.

_SC_VERSION (Not supported by the System i product). Represents the _POSIX_VERSION macro, which indicates the version of the POSIX.1 standard that the system conforms to. If the macro exists, it is defined in the <unistd.h> header file.

_SC_CCSID Represents the default coded character set identifier (CCSID) used internally for integrated file system path names. A CCSID uniquely identifies the coded graphic character representation of a path name and includes such information as the character set and code page identifier. The symbol _SC_CCSID is defined as the decimal value 10.


Authorities

No authorization is required.


Return Value

value sysconf() was successful. The value associated with the specified option is returned.
-1 One of the following has occurred:
  • The variable corresponding to name is valid but is not supported by the system. The errno global variable is not changed.
  • sysconf() failed in some other way. The errno is set to indicate the error.


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 condition Additional information
[EBADFID]  
[EINVAL]  


Error Messages

The following messages may be sent from this function:

Message ID Error Message Text
CPE3418 E Possible APAR condition or hardware failure.
CPF3CF2 E Error(s) occurred during running of &1 API.


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 ]