Return the value of a configurable system limit or option
Synopsis:
#include <unistd.h>
#include <limits.h>
long sysconf( int name );
Arguments:
- name
- The name of the system limit or option that you want to get; see below.
Library:
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
Description:
The sysconf() function returns the value of a
system variable (a configurable limit or option) indicated by name.
System variables are defined in <confname.h>, and include at
least the following values:
- _SC_AIO_PRIO_DELTA_MAX
- The maximum amount by which a process can decrease its asynchronous I/O
priority level from its own scheduling priority.
- _SC_ARG_MAX
- Maximum length of arguments for the exec*() functions,
in bytes, including environment data.
- _SC_CHILD_MAX
- Maximum number of simultaneous processes per real user ID.
- _SC_CLK_TCK
- The number of intervals per second used to express the value in type clock_t.
- _SC_DELAYTIMER_MAX
- The maximum number of times a timer can overrun and you can still detect it.
- _SC_GETGR_R_SIZE_MAX
- If defined (not -1), the maximum size of buffer that you need to supply to
getgrgid_r()
for any memory that it needs to allocate.
- _SC_GETPW_R_SIZE_MAX
- If defined (not -1), the maximum size of buffer that you need to supply to
getpwent_r(),
getpwuid_r(),
getspent_r(),
or
getspnam_r()
for any memory that they need to allocate.
- _SC_JOB_CONTROL
- If this variable is defined, then job control is supported.
- _SC_MQ_OPEN_MAX
- The maximum number of open message queue descriptors a process may hold.
This variable is set only while
mq
or
mqueue
is running.
- _SC_MQ_PRIO_MAX
- The maximum number of message priorities.
This variable is set only while
mq
or
mqueue
is running.
- _SC_NGROUPS_MAX
- The maximum number of simultaneous supplementary group IDs per process.
- _SC_OPEN_MAX
- Maximum number of files that one process can have open at any given time.
- _SC_PAGESIZE or _SC_PAGE_SIZE
- The size in bytes of a page.
- _SC_RCT_MEM
- The minimum amount of memory that the system retains as a resource constraint threshold.
Only an unconstrained process (i.e., one with the PROCMGR_AID_RCONSTRAINT
ability enabled—see
procmgr_ability())
can allocate memory if there's less than this amount left.
- _SC_RCT_SCOID
- The minimum number of connection IDs that a server retains as a resource constraint threshold.
Only an unconstrained process (i.e., one with the PROCMGR_AID_RCONSTRAINT
ability enabled—see
procmgr_ability())
can create a connection if there are fewer than this number left.
- _SC_SAVED_IDS
- If this variable is defined, then each process has a saved set-user ID
and a saved set-group ID.
- _SC_SEM_NSEMS_MAX
- The maximum number of semaphores that one process can have open at a time.
The sysconf() function returns -1 to indicate that this value
is indeterminate because that limit applies to both named and unnamed semaphores.
The kernel allows an arbitrary number of unnamed semaphores
(they're kernel synchronization objects, so the number of them is limited
only by the amount of available kernel memory).
- _SC_SIGQUEUE_MAX
- The maximum number of outstanding realtime signals sent per process.
- _SC_THREAD_STACK_MIN
- The minimum stack size for a thread.
- _SC_TZNAME_MAX
- The maximum length of the names for time zones.
The value is the same as TZNAME_MAX.
- _SC_VERSION
- The current POSIX version that is currently supported.
A value of 198808L indicates the August (08) 1988 standard, as approved by the
IEEE Standards Board.
Returns:
The requested configurable system limit or option.
If name isn't defined for the system, -1 is returned.
Examples:
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <unistd.h>
int main( void )
{
printf( "_SC_ARG_MAX = %ld\n",
sysconf( _SC_ARG_MAX ) );
return EXIT_SUCCESS;
}
Classification:
POSIX 1003.1
Safety: |
|
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |