SYSCONF(3P)
SYSCONF(3P) ๐ POSIX Programmer's Manual ๐
okay bestie, buckle up, because this one's a whole POSIX Programmer's Manual page and it's lowkey long, but we're gonna get through it together, no cap โจ
๐ธ PROLOG ๐ธ
This manual page is part of the POSIX Programmer's Manual. Heads up though, because the vibes get โจcomplicatedโจ:
- The Linux implementation of this interface may differ โ so if you're on Linux, go consult the corresponding Linux manual page for the actual deets on Linux behavior, fr fr.
- Or the interface may not be implemented on Linux at all. Not every queen gets invited to every party, and that's just how it is ๐
Not me warning you about platform differences in the prolog. We're literally two paragraphs in. This is giving "read the fine print" energy and honestly? Respect it.
โจ NAME โจ
sysconf โ get configurable system variables ๐ฆ
๐ SYNOPSIS ๐
#include <unistd.h>
long sysconf(int name);
short, sweet, iconic, main character energy ๐
๐ง DESCRIPTION ๐ง
So here's the tea, bestie โ
The sysconf() function is the way your application goes and asks the system what's up. Specifically, it provides a method for the application to determine the current value of a configurable system limit or option (a variable, basically). Like, "hey system, what's your number for this thing?" and the system tells you ๐ซถ
And here's the important part, so listen up:
- The implementation shall support all of the variables listed in the following table
- It may support others โ so if you see extra variables out there, that's allowed, she's just being generous ๐
the way that a function can just. ask. and the system answers. obsessed.
aaaand that's the setup, bestie โ the actual table of variables is coming in the next part, so don't go anywhere ๐
okay so bestie, the name argument is literally the system variable you're trying to query. the following list is the minimal set of system variables from <limits.h> or <unistd.h> that can be returned by sysconf(), plus the symbolic constants defined in <unistd.h> that are the corresponding values used for name. periodt ๐
here's the whole lineup, variable on the left, the constant you pass as name on the right:
{AIO_LISTIO_MAX}โ_SC_AIO_LISTIO_MAX{AIO_MAX}โ_SC_AIO_MAX{AIO_PRIO_DELTA_MAX}โ_SC_AIO_PRIO_DELTA_MAX{ARG_MAX}โ_SC_ARG_MAX{ATEXIT_MAX}โ_SC_ATEXIT_MAX{BC_BASE_MAX}โ_SC_BC_BASE_MAX{BC_DIM_MAX}โ_SC_BC_DIM_MAX{BC_SCALE_MAX}โ_SC_BC_SCALE_MAX{BC_STRING_MAX}โ_SC_BC_STRING_MAX{CHILD_MAX}โ_SC_CHILD_MAX- Clock ticks/second โ
_SC_CLK_TCK {COLL_WEIGHTS_MAX}โ_SC_COLL_WEIGHTS_MAX{DELAYTIMER_MAX}โ_SC_DELAYTIMER_MAX{EXPR_NEST_MAX}โ_SC_EXPR_NEST_MAX{HOST_NAME_MAX}โ_SC_HOST_NAME_MAX{IOV_MAX}โ_SC_IOV_MAX{LINE_MAX}โ_SC_LINE_MAX{LOGIN_NAME_MAX}โ_SC_LOGIN_NAME_MAX{NGROUPS_MAX}โ_SC_NGROUPS_MAX- Initial size of
getgrgid_r()andgetgrnam_r()data buffers โ_SC_GETGR_R_SIZE_MAX - Initial size of
getpwuid_r()andgetpwnam_r()data buffers โ_SC_GETPW_R_SIZE_MAX {MQ_OPEN_MAX}โ_SC_MQ_OPEN_MAX{MQ_PRIO_MAX}โ_SC_MQ_PRIO_MAX{OPEN_MAX}โ_SC_OPEN_MAX{PAGE_SIZE}โ_SC_PAGE_SIZE{PAGESIZE}โ_SC_PAGESIZE{PTHREAD_DESTRUCTOR_ITERATIONS}โ_SC_THREAD_DESTRUCTOR_ITERATIONS{PTHREAD_KEYS_MAX}โ_SC_THREAD_KEYS_MAX{PTHREAD_STACK_MIN}โ_SC_THREAD_STACK_MIN{PTHREAD_THREADS_MAX}โ_SC_THREAD_THREADS_MAX{RE_DUP_MAX}โ_SC_RE_DUP_MAX{RTSIG_MAX}โ_SC_RTSIG_MAX{SEM_NSEMS_MAX}โ_SC_SEM_NSEMS_MAX{SEM_VALUE_MAX}โ_SC_SEM_VALUE_MAX{SIGQUEUE_MAX}โ_SC_SIGQUEUE_MAX{STREAM_MAX}โ_SC_STREAM_MAX{SYMLOOP_MAX}โ_SC_SYMLOOP_MAX{TIMER_MAX}โ_SC_TIMER_MAX{TTY_NAME_MAX}โ_SC_TTY_NAME_MAX{TZNAME_MAX}โ_SC_TZNAME_MAX_POSIX_ADVISORY_INFOโ_SC_ADVISORY_INFO_POSIX_BARRIERSโ_SC_BARRIERS_POSIX_ASYNCHRONOUS_IOโ_SC_ASYNCHRONOUS_IO_POSIX_CLOCK_SELECTIONโ_SC_CLOCK_SELECTION_POSIX_CPUTIMEโ_SC_CPUTIME_POSIX_FSYNCโ_SC_FSYNC_POSIX_IPV6โ_SC_IPV6_POSIX_JOB_CONTROLโ_SC_JOB_CONTROL_POSIX_MAPPED_FILESโ_SC_MAPPED_FILES_POSIX_MEMLOCKโ_SC_MEMLOCK_POSIX_MEMLOCK_RANGEโ_SC_MEMLOCK_RANGE_POSIX_MEMORY_PROTECTIONโ_SC_MEMORY_PROTECTION_POSIX_MESSAGE_PASSINGโ_SC_MESSAGE_PASSING_POSIX_MONOTONIC_CLOCKโ_SC_MONOTONIC_CLOCK_POSIX_PRIORITIZED_IOโ_SC_PRIORITIZED_IO_POSIX_PRIORITY_SCHEDULINGโ_SC_PRIORITY_SCHEDULING_POSIX_RAW_SOCKETSโ_SC_RAW_SOCKETS_POSIX_READER_WRITER_LOCKSโ_SC_READER_WRITER_LOCKS_POSIX_REALTIME_SIGNALSโ_SC_REALTIME_SIGNALS_POSIX_REGEXPโ_SC_REGEXP_POSIX_SAVED_IDSโ_SC_SAVED_IDS_POSIX_SEMAPHORESโ_SC_SEMAPHORES_POSIX_SHARED_MEMORY_OBJECTSโ_SC_SHARED_MEMORY_OBJECTS_POSIX_SHELLโ_SC_SHELL_POSIX_SPAWNโ_SC_SPAWN_POSIX_SPIN_LOCKSโ_SC_SPIN_LOCKS_POSIX_SPORADIC_SERVERโ_SC_SPORADIC_SERVER_POSIX_SS_REPL_MAXโ_SC_SS_REPL_MAX_POSIX_SYNCHRONIZED_IOโ_SC_SYNCHRONIZED_IO_POSIX_THREAD_ATTR_STACKADDRโ_SC_THREAD_ATTR_STACKADDR_POSIX_THREAD_ATTR_STACKSIZEโ_SC_THREAD_ATTR_STACKSIZE_POSIX_THREAD_CPUTIMEโ_SC_THREAD_CPUTIME_POSIX_THREAD_PRIO_INHERITโ_SC_THREAD_PRIO_INHERIT_POSIX_THREAD_PRIO_PROTECTโ_SC_THREAD_PRIO_PROTECT_POSIX_THREAD_PRIORITY_SCHEDULINGโ_SC_THREAD_PRIORITY_SCHEDULING_POSIX_THREAD_PROCESS_SHAREDโ_SC_THREAD_PROCESS_SHARED_POSIX_THREAD_ROBUST_PRIO_INHERITโ_SC_THREAD_ROBUST_PRIO_INHERIT_POSIX_THREAD_ROBUST_PRIO_PROTECTโ_SC_THREAD_ROBUST_PRIO_PROTECT_POSIX_THREAD_SAFE_FUNCTIONSโ_SC_THREAD_SAFE_FUNCTIONS_POSIX_THREAD_SPORADIC_SERVERโ_SC_THREAD_SPORADIC_SERVER_POSIX_THREADSโ_SC_THREADS_POSIX_TIMEOUTSโ_SC_TIMEOUTS_POSIX_TIMERSโ_SC_TIMERS_POSIX_TRACEโ_SC_TRACE_POSIX_TRACE_EVENT_FILTERโ_SC_TRACE_EVENT_FILTER_POSIX_TRACE_EVENT_NAME_MAXโ_SC_TRACE_EVENT_NAME_MAX_POSIX_TRACE_INHERITโ_SC_TRACE_INHERIT_POSIX_TRACE_LOGโ_SC_TRACE_LOG_POSIX_TRACE_NAME_MAXโ_SC_TRACE_NAME_MAX_POSIX_TRACE_SYS_MAXโ_SC_TRACE_SYS_MAX_POSIX_TRACE_USER_EVENT_MAXโ_SC_TRACE_USER_EVENT_MAX_POSIX_TYPED_MEMORY_OBJECTSโ_SC_TYPED_MEMORY_OBJECTS_POSIX_VERSIONโ_SC_VERSION_POSIX_V7_ILP32_OFF32โ_SC_V7_ILP32_OFF32_POSIX_V7_ILP32_OFFBIGโ_SC_V7_ILP32_OFFBIG_POSIX_V7_LP64_OFF64โ_SC_V7_LP64_OFF64_POSIX_V7_LPBIG_OFFBIGโ_SC_V7_LPBIG_OFFBIG_POSIX_V6_ILP32_OFF32โ_SC_V6_ILP32_OFF32_POSIX_V6_ILP32_OFFBIGโ_SC_V6_ILP32_OFFBIG_POSIX_V6_LP64_OFF64โ_SC_V6_LP64_OFF64_POSIX_V6_LPBIG_OFFBIGโ_SC_V6_LPBIG_OFFBIG_POSIX2_C_BINDโ_SC_2_C_BIND_POSIX2_C_DEVโ_SC_2_C_DEV_POSIX2_CHAR_TERMโ_SC_2_CHAR_TERM_POSIX2_FORT_DEVโ_SC_2_FORT_DEV_POSIX2_FORT_RUNโ_SC_2_FORT_RUN_POSIX2_LOCALEDEFโ_SC_2_LOCALEDEF_POSIX2_PBSโ_SC_2_PBS_POSIX2_PBS_ACCOUNTINGโ_SC_2_PBS_ACCOUNTING_POSIX2_PBS_CHECKPOINTโ_SC_2_PBS_CHECKPOINT_POSIX2_PBS_LOCATEโ_SC_2_PBS_LOCATE_POSIX2_PBS_MESSAGEโ_SC_2_PBS_MESSAGE_POSIX2_PBS_TRACKโ_SC_2_PBS_TRACK_POSIX2_SW_DEVโ_SC_2_SW_DEV_POSIX2_UPEโ_SC_2_UPE_POSIX2_VERSIONโ_SC_2_VERSION_XOPEN_CRYPTโ_SC_XOPEN_CRYPT_XOPEN_ENH_I18Nโ_SC_XOPEN_ENH_I18N_XOPEN_REALTIMEโ_SC_XOPEN_REALTIME_XOPEN_REALTIME_THREADSโ_SC_XOPEN_REALTIME_THREADS_XOPEN_SHMโ_SC_XOPEN_SHM_XOPEN_STREAMSโ_SC_XOPEN_STREAMS_XOPEN_UNIXโ_SC_XOPEN_UNIX_XOPEN_UUCPโ_SC_XOPEN_UUCP
_XOPEN_VERSION โ _SC_XOPEN_VERSION
โจ RETURN VALUE โจ
Okay so bestie, here's the tea on what sysconf() gives back. ๐ซ
If name is an invalid value, sysconf() shall return -1 and set errno to indicate the error. ๐
If the variable corresponding to name is described in <limits.h> as a maximum or minimum value and the variable has no limit, sysconf() shall return -1 without changing the value of errno. And just so you know: indefinite limits do not imply infinite limits โ see <limits.h> for the deets. ๐
Otherwise, sysconf() shall return the current variable value on the system. The value returned shall not be more restrictive than the corresponding value described to the application when it was compiled with the implementation's <limits.h> or <unistd.h>. The value shall not change during the lifetime of the calling process, except that sysconf(_SC_OPEN_MAX) may return different values before and after a call to setrlimit() which changes the RLIMIT_NOFILE soft limit. ๐
If the variable corresponding to name is dependent on an unsupported option, the results are unspecified. ๐คทโโ๏ธ
๐ ERRORS ๐
The sysconf() function shall fail if:
EINVALโ The value of thenameargument is invalid. ๐ซ
The following sections are informative. ๐
๐ธ EXAMPLES ๐ธ
None. ๐โโ๏ธ
๐ซถ APPLICATION USAGE ๐ซถ
As -1 is a permissible return value in a successful situation, an application wishing to check for error situations should set errno to 0, then call sysconf(), and, if it returns -1, check to see if errno is non-zero. ๐ต๏ธโโ๏ธ
Application developers should check whether an option, such as _POSIX_TRACE, is supported prior to obtaining and using values for related variables, such as _POSIX_TRACE_NAME_MAX. โ
๐ง RATIONALE ๐ง
This functionality was added in response to requirements of application developers and of system vendors who deal with many international system configurations. It is closely related to pathconf() and fpathconf(). ๐
Although a conforming application can run on all systems by never demanding more resources than the minimum values published in this volume of POSIX.1โ2017, it is useful for that application to be able to use the actual value for the quantity of a resource available on any given system. To do this, the application makes use of the value of a symbolic constant in <limits.h> or <unistd.h>. ๐
However, once compiled, the application must still be able to cope if the amount of resource available is increased. To that end, an application may need a means of determining the quantity of a resource, or the presence of an option, at execution time. โณ
Two examples are offered:
- Applications may wish to act differently on systems with or without job control. Applications vendors who wish to distribute only a single binary package to all instances of a computer architecture would be forced to assume job control is never available if it were to rely solely on the
<unistd.h>value published in this volume of POSIX.1โ2017. ๐ผ - International applications vendors occasionally require knowledge of the number of clock ticks per second. Without these facilities, they would be required to either distribute their applications partially in source form or to have 50 Hz and 60 Hz versions for the various countries in which they operate. โฐ
It is the knowledge that many applications are actually distributed widely in executable form that leads to this facility. If limited to the most restrictive values in the headers, such applications would have to be prepared to accept the most limited environments offered by the smallest microcomputers. Although this is entirely portable, there was a consensus that they should be able to take advantage of the facilities offered by large systems, without the restrictions associated with source and object distributions. ๐ฅ๏ธ
During the discussions of this feature, it was pointed out that it is almost always possible for an application to discern what a value might be at runtime by suitably testing the various functions themselves. And, in any event, it could always be written to adequately deal with error returns from the various functions. In the end, it was felt that this imposed an unreasonable level of complication and sophistication on the application developer. ๐ค
This runtime facility is not meant to provide ever-changing values that applications have to check multiple times. The values are seen as changing no more frequently than once per system initialization, such as by a system administrator or operator with an automatic configuration program. This volume of POSIX.1โ2017 specifies that they shall not change within the lifetime of the process. ๐
Some values apply to the system overall and others vary at the file system or directory level. The latter are described in fpathconf(). ๐
Note that all values returned must be expressible as integers. String values were considered, but the additional flexibility of this approach was rejected due to its added complexity of implementation and use. ๐ข
Some values, such as {PATH_MAX}, are sometimes so large that they must not be used to, say, allocate arrays. The sysconf() function returns a negative value to show that this symbolic constant is not even defined in this case. ๐ซ
Similar to pathconf(), this permits the implementation not to have a limit. When one resource is infinite, returning an error indicating that some other resource limit has been reached is conforming behavior. โพ๏ธ
๐ฎ FUTURE DIRECTIONS ๐ฎ
None. ๐ฎ
๐ SEE ALSO ๐
confstr(),fpathconf()- The Base Definitions volume of POSIX.1โ2017,
<limits.h>,<unistd.h> - The Shell and Utilities volume of POSIX.1โ2017,
getconf
๐ COPYRIGHT ๐
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . ๐
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html . ๐
This iconic page is brought to you by IEEE/The Open Group, 2017, and it's SYSCONF(3P) fr fr. Periodt. ๐ โจ
๐ฆ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 ยท custom
- alpine 3.23: man-pages-posix 2017a-r0 ยท custom
- alpine 3.24: man-pages-posix 2017a-r0 ยท custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 ยท SUSE-IEEE
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms