SYSCONF(3POSIX)
π SYSCONF(3POSIX) π
POSIX Programmer's Manual Β· SYSCONF(3POSIX)
okay bestie, buckle up, we're doing a POSIX manual page together and honestly? it's gonna slay π«Ά
πΈ PROLOG πΈ
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
π real talk: just because it's in the POSIX manual doesn't mean your Linux box does it exactly the same way, and sometimes it doesn't do it at all. check the Linux page before you get attached, iykyk.
β¨ NAME β¨
sysconf β get configurable system variables π
π SYNOPSIS π
#include <unistd.h>
long sysconf(int name);
π¦ DESCRIPTION π¦
So the sysconf() function is literally your way of asking the system "hey, what's the deal with this limit or option rn?" π
It provides a method for the application to determine the current value of a configurable system limit or option (variable).
And here's the part that matters: the implementation shall support all of the variables listed in the following table β and it may support others too. no cap.
β¦and bestie, that table is coming right up, so don't go anywhere π
Okay so the name argument? That's literally the thing you're asking about β it's the system variable you wanna query. π And here's the tea: there's a minimum set of system variables from <limits.h> or <unistd.h> that sysconf() is allowed to hand back, and each one has a symbolic constant defined in <unistd.h> that you pass in as name. Match them up like a bestie matching outfits. π
<h2>β¨ The Variable β Name Matching Game β¨</h2>
First half of the lineup, bestie β variable on the left, the name value you actually pass 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
<h2>β¨ The List Continues (yes there's more, she's thorough) β¨</h2>
Second half, same energy, same rules β the variable, then the name you feed in:
_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
Lowkey that's a lot of names and bestie you are not expected to memorise them β that's what the headers are for. π«Ά Next part's got more, stay tuned. β¨
_XOPEN_VERSIONβΆ_SC_XOPEN_VERSIONβ the last lil row of the mapping table, rescued from the top of this part bestie, she made it π
β¨ RETURN VALUE β¨
okay so here's the tea on what sysconf() hands back π
If name is an invalid value, sysconf() shall return -1 and set errno to indicate the error. that's a real error, bestie π
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. sneaky!! Note that indefinite limits do not imply infinite limits; see <limits.h>.
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, iconic stability behavior except that sysconf(_SC_OPEN_MAX) may return different values before and after a call to setrlimit() which changes the RLIMIT_NOFILE soft limit. the one glow-up exception fr fr
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 the name argument is invalid. not a vibe
The following sections are informative.
πΈ EXAMPLES πΈ
None.
she said "no examples, figure it out bestie" π
π 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. that's the whole trick, that's the move β¨
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. vibe check the option first, then grab the numbers π¦
π 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(). siblings!!
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. runtime info era
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. one binary to rule them all, allegedly - 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 Hzand60 Hzversions for the various countries in which they operate. not the 50/60 Hz split π
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. portable but also not stuck in the small-computer basement, slay
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. too much work, committee said no π
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. set it once, chill forever
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. no strings attached, literally
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. do NOT malloc that bestie π«Ά
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. weird but legal
π FUTURE DIRECTIONS π
None.
the future said "no comment" π
π₯ 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 .
okay bestie that's the whole page, we did it π this queen is stamped IEEE/The Open Group, dated 2017, and filed under SYSCONF(3POSIX) β go forth and sysconf() responsibly, mwah πβ¨π¦
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms