#include <unistd.h> long sysconf(int configOpt);
sysconf
returns the value of a system configuration option.
The configOpt
argument can be any of the following symbols,
which specify the system configuration option to determine.
_SC_ARG_MAX
ARG_MAX
, which specifies the maximum
number of bytes of argument and environment data that can be
passed to an exec
function.
_SC_CHILD_MAX
CHILD_MAX
, which specifies the maximum
number of child processes that a user ID (UID) can have running
at the same time.
_SC_CLK_TCK
CLK_TCK
macro, which is defined
in <time.h>
. This macro specifies the number of clock ticks
in a second.
_SC_JOB_CONTROL
_POSIX_JOB_CONTROL
macro, which may
be defined in <unistd.h>
. This macro specifies that
certain job control functions are implemented by the operating
system. Certain functions, such as setpgid
, will
have more functionality if _POSIX_JOB_CONTROL
is defined.
_SC_NGROUPS_MAX
NGROUPS_MAX
, which specifies the
maximum number of supplementary group IDs (GIDs) that can be
associated with a process.
_SC_OPEN_MAX
OPEN_MAX
, which specifies the
maximum number of files that a single process can have open at one
time.
_SC_SAVED_IDS
SAVED_IDS
macro, which may be defined
in <unistd.h>
. This macro specifies that a saved set UID
and a saved set GID are implemented. The behavior of certain functions,
such as setuid
and setgid
, is affected by this
macro.
_SC_STREAM_MAX
STREAM_MAX
macro, which may be
defined in <unistd.h>
. This macro indicates the maximum
number of streams that a process can have open simultaneously.
_SC_TZNAME_MAX
TZNAME_MAX
macro, which may be
defined in <unistd.h>
. This macro indicates the maximum
length of the name of a time zone.
_SC_VERSION
VERSION
macro, which may be
defined in <unistd.h>
. This macro indicates the version
of the POSIX.1 standard that the system conforms to.
sysconf
returns the value associated with the option specified
by the configOpt
argument. If the symbol corresponding to
the specified option exists but is not supported, sysconf
returns - 1
but does not change the value of errno
. If
sysconf
fails in any other way, it returns - 1
and sets errno
to EINVAL
.
sysconf
to
obtain the value of STREAM_MAX
:
#include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <errno.h> main() { int max_streams; errno = 0; if ((max_streams = sysconf(_SC_STREAM_MAX)) == -1) if (errno == 0) printf("STREAM_MAX not supported by this implementation.n"); else perror("sysconf error."); else printf("STREAM_MAX = %dn", max_streams); }
fpathconf
, pathconf
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.