unistd.h(0P)
okay bestie, welcome to the POSIX Programmer's Manual page for unistd.h(0P). ๐ This is the header that's giving standard symbolic constants and types realness.
๐ 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 on Linux behavior), or the interface may not be implemented on Linux.
no cap, if you're on Linux, go peek at the Linux manual page too. ๐ง
โจ NAME โจ
unistd.h โ standard symbolic constants and types
๐ฆ SYNOPSIS ๐ฆ
#include <unistd.h>
๐ DESCRIPTION ๐
The <unistd.h> header defines miscellaneous symbolic constants and types, and declares miscellaneous functions. The actual values of the constants are unspecified except as shown. The contents of this header are shown below.
๐ Version Test Macros ๐
The <unistd.h> header shall define the following symbolic constants. The values shall be suitable for use in #if preprocessing directives.
_POSIX_VERSIONโ Integer value indicating version of this standard (C-language binding) to which the implementation conforms. For implementations conforming to POSIX.1โ2008, the value shall be200809L._POSIX2_VERSIONโ Integer value indicating version of the Shell and Utilities volume of POSIX.1 to which the implementation conforms. For implementations conforming to POSIX.1โ2008, the value shall be200809L. For profile implementations that define_POSIX_SUBPROFILE(see Section 2.1.5.1, Subprofiling Considerations) in<unistd.h>,_POSIX2_VERSIONmay be left undefined or be defined with the value-1to indicate that the Shell and Utilities volume of POSIX.1 is not supported. In this case, a call tosysconf(_SC_2_VERSION)shall return either200809Lor-1indicating that the Shell and Utilities volume of POSIX.1 is or is not, respectively, supported at runtime.
The <unistd.h> header shall define the following symbolic constant only if the implementation supports the XSI option; see Section 2.1.4, XSI Conformance. If defined, its value shall be suitable for use in #if preprocessing directives.
_XOPEN_VERSIONโ Integer value indicating version of the X/Open Portability Guide to which the implementation conforms. The value shall be700.
๐ Constants for Options and Option Groups ๐
The following symbolic constants, if defined in <unistd.h>, shall have a value of -1, 0, or greater, unless otherwise specified below. For profile implementations that define _POSIX_SUBPROFILE (see Section 2.1.5.1, Subprofiling Considerations) in <unistd.h>, constants described below as always having a value greater than zero need not be defined and, if defined, may have a value of -1, 0, or greater. The values shall be suitable for use in #if preprocessing directives.
If a symbolic constant is not defined or is defined with the value -1, the option is not supported for compilation. If it is defined with a value greater than zero, the option shall always be supported when the application is executed. If it is defined with the value zero, the option shall be supported for compilation and might or might not be supported at runtime. See Section 2.1.6, Options for further information about the conformance requirements of these three categories of support.
_POSIX_ADVISORY_INFOโ The implementation supports the Advisory Information option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_ASYNCHRONOUS_IOโ The implementation supports asynchronous input and output. This symbol shall always be set to the value200809L._POSIX_BARRIERSโ The implementation supports barriers. This symbol shall always be set to the value200809L._POSIX_CHOWN_RESTRICTEDโ The use ofchown()andfchown()is restricted to a process with appropriate privileges, and to changing the group ID of a file only to the effective group ID of the process or to one of its supplementary group IDs. This symbol shall be defined with a value other than-1._POSIX_CLOCK_SELECTIONโ The implementation supports clock selection. This symbol shall always be set to the value200809L._POSIX_CPUTIMEโ The implementation supports the Process CPU-Time Clocks option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_FSYNCโ The implementation supports the File Synchronization option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_IPV6โ The implementation supports the IPv6 option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_JOB_CONTROLโ The implementation supports job control. This symbol shall always be set to a value greater than zero._POSIX_MAPPED_FILESโ The implementation supports memory mapped Files. This symbol shall always be set to the value200809L._POSIX_MEMLOCKโ The implementation supports the Process Memory Locking option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_MEMLOCK_RANGEโ The implementation supports the Range Memory Locking option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_MEMORY_PROTECTIONโ The implementation supports memory protection. This symbol shall always be set to the value200809L._POSIX_MESSAGE_PASSINGโ The implementation supports the Message Passing option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_MONOTONIC_CLOCKโ The implementation supports the Monotonic Clock option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_NO_TRUNCโ Pathname components longer than{NAME_MAX}generate an error. This symbol shall be defined with a value other than-1._POSIX_PRIORITIZED_IOโ The implementation supports the Prioritized Input and Output option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_PRIORITY_SCHEDULINGโ The implementation supports the Process Scheduling option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_RAW_SOCKETSโ The implementation supports the Raw Sockets option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_READER_WRITER_LOCKSโ The implementation supports read-write locks. This symbol shall always be set to the value200809L._POSIX_REALTIME_SIGNALSโ The implementation supports realtime signals. This symbol shall always be set to the value200809L._POSIX_REGEXPโ The implementation supports the Regular Expression Handling option. This symbol shall always be set to a value greater than zero._POSIX_SAVED_IDSโ Each process has a saved set-user-ID and a saved set-group-ID. This symbol shall always be set to a value greater than zero._POSIX_SEMAPHORESโ The implementation supports semaphores. This symbol shall always be set to the value200809L._POSIX_SHARED_MEMORY_OBJECTSโ The implementation supports the Shared Memory Objects option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_SHELLโ The implementation supports the POSIX shell. This symbol shall always be set to a value greater than zero._POSIX_SPAWNโ The implementation supports the Spawn option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_SPIN_LOCKSโ The implementation supports spin locks. This symbol shall always be set to the value200809L._POSIX_SPORADIC_SERVERโ The implementation supports the Process Sporadic Server option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_SYNCHRONIZED_IOโ The implementation supports the Synchronized Input and Output option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_THREAD_ATTR_STACKADDRโ The implementation supports the Thread Stack Address Attribute option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_THREAD_ATTR_STACKSIZEโ The implementation supports the Thread Stack Size Attribute option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_THREAD_CPUTIMEโ The implementation supports the Thread CPU-Time Clocks option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_THREAD_PRIO_INHERITโ The implementation supports the Non-Robust Mutex Priority Inheritance option. If this symbol is defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall either be-1or200809L._POSIX_THREAD_PRIO_PROTECTโ ok so this means the implementation supports the Non-Robust Mutex Priority Protection option ๐ . If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L. And whatever valuesysconf()reports for it shall be either-1or200809Lโ those are the only two moods it's allowed to have, fr._POSIX_THREAD_PRIORITY_SCHEDULINGโ this one says the implementation supports the Thread Execution Scheduling option โจ. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The valuesysconf()reports for it shall be either-1or200809L._POSIX_THREAD_PROCESS_SHAREDโ supports the Thread Process-Shared Synchronization option ๐ฆ. Defined in<unistd.h>? Then it shall be-1,0, or200809L. Andsysconf()'s reported value shall be either-1or200809L. no cap._POSIX_THREAD_ROBUST_PRIO_INHERITโ this is the Robust Mutex Priority Inheritance option ๐. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L.sysconf()reporting it shall give either-1or200809L._POSIX_THREAD_ROBUST_PRIO_PROTECTโ Robust Mutex Priority Protection, yes ma'am ๐. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The valuesysconf()reports shall be either-1or200809L._POSIX_THREAD_SAFE_FUNCTIONSโ implementation supports thread-safe functions ๐ธ. This symbol shall always be set to the value200809L. no wiggle room, that's the vibe._POSIX_THREAD_SPORADIC_SERVERโ supports the Thread Sporadic Server option ๐. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L, andsysconf()shall report either-1or200809L._POSIX_THREADSโ the implementation supports threads ๐งตโจ. This symbol shall always be set to the value200809L. iconic._POSIX_TIMEOUTSโ supports timeouts โณ. This symbol shall always be set to the value200809L._POSIX_TIMERSโ supports timers โฐ. This symbol shall always be set to the value200809L._POSIX_TRACEโ supports the Trace option ๐. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The valuesysconf()reports shall be either-1or200809L._POSIX_TRACE_EVENT_FILTERโ supports the Trace Event Filter option ๐ซถ. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L. Andsysconf()shall report either-1or200809L._POSIX_TRACE_INHERITโ supports the Trace Inherit option ๐. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The valuesysconf()reports shall be either-1or200809L._POSIX_TRACE_LOGโ supports the Trace Log option ๐. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L.sysconf()'s value shall be either-1or200809L._POSIX_TYPED_MEMORY_OBJECTSโ supports the Typed Memory Objects option ๐ง . If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The valuesysconf()reports shall be either-1or200809L.
ok now we're getting into the data model girlies, and this is where it gets SPICY ๐ถ๏ธ because it's all about how many bits each type has. pay attention bestie:
_POSIX_V6_ILP32_OFF32โ the implementation provides a C-language compilation environment with 32-bitint,long,pointer, andoff_ttypes. so. many. 32s._POSIX_V6_ILP32_OFFBIGโ the implementation provides a C-language compilation environment with 32-bitint,long, andpointertypes, plus anoff_ttype using at least 64 bits ๐._POSIX_V6_LP64_OFF64โ the implementation provides a C-language compilation environment with 32-bitintand 64-bitlong,pointer, andoff_ttypes โจ._POSIX_V6_LPBIG_OFFBIGโ the implementation provides a C-language compilation environment with aninttype using at least 32 bits andlong,pointer, andoff_ttypes using at least 64 bits ๐_POSIX_V7_ILP32_OFF32โ the implementation provides a C-language compilation environment with 32-bitint,long,pointer, andoff_ttypes._POSIX_V7_ILP32_OFFBIGโ the implementation provides a C-language compilation environment with 32-bitint,long, andpointertypes and anoff_ttype using at least 64 bits ๐ ._POSIX_V7_LP64_OFF64โ the implementation provides a C-language compilation environment with 32-bitintand 64-bitlong,pointer, andoff_ttypes ๐._POSIX_V7_LPBIG_OFFBIGโ the implementation provides a C-language compilation environment with aninttype using at least 32 bits andlong,pointer, andoff_ttypes using at least 64 bits ๐.
back to the option-y ones, bestie, we're not done yet:
_POSIX2_C_BINDโ supports the C-Language Binding option ๐. This symbol shall always have the value200809L._POSIX2_C_DEVโ supports the C-Language Development Utilities option ๐ ๏ธ. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The valuesysconf()reports shall be either-1or200809L._POSIX2_CHAR_TERMโ supports the Terminal Characteristics option ๐ฅ๏ธ. The value of this symbol reported bysysconf()shall be either-1or a value greater than zero. (note: no200809Lrequirement here, she's special ๐ )_POSIX2_FORT_DEVโ supports the FORTRAN Development Utilities option ๐ฐ. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The valuesysconf()reports shall be either-1or200809L._POSIX2_FORT_RUNโ supports the FORTRAN Runtime Utilities option ๐. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L.sysconf()shall report either-1or200809L._POSIX2_LOCALEDEFโ supports the creation of locales by thelocaledefutility ๐. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The valuesysconf()reports shall be either-1or200809L._POSIX2_PBSโ supports the Batch Environment Services and Utilities option ๐ฆ. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L.sysconf()'s value shall be either-1or200809L._POSIX2_PBS_ACCOUNTINGโ supports the Batch Accounting option ๐งพ. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The valuesysconf()reports shall be either-1or200809L._POSIX2_PBS_CHECKPOINTโ supports the Batch Checkpoint/Restart option ๐พ. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L.sysconf()shall report either-1or200809L._POSIX2_PBS_LOCATEโ supports the Locate Batch Job Request option ๐. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The valuesysconf()reports shall be either-1or200809L._POSIX2_PBS_MESSAGEโ supports the Batch Job Message Request option ๐ฌ. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L.sysconf()'s reported value shall be either-1or200809L._POSIX2_PBS_TRACKโ supports the Track Batch Job Request option ๐ฐ๏ธ. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The valuesysconf()reports shall be either-1or200809L._POSIX2_SW_DEVโ supports the Software Development Utilities option ๐งฐ. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The valuesysconf()reports shall be either-1or200809L._POSIX2_UPEโ supports the User Portability Utilities option ๐งณ. If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L.sysconf()shall report either-1or200809L.
and now the X/Open girlies, they're a whole different breed ๐ :
_XOPEN_CRYPTโ supports the X/Open Encryption Option Group ๐._XOPEN_ENH_I18Nโ supports the Issue 4, Version 2 Enhanced Internationalization Option Group ๐. This symbol shall always be set to a value other than-1._XOPEN_REALTIMEโ supports the X/Open Realtime Option Group โก._XOPEN_REALTIME_THREADSโ supports the X/Open Realtime Threads Option Group ๐งตโก._XOPEN_SHMโ supports the Issue 4, Version 2 Shared Memory Option Group ๐ค. This symbol shall always be set to a value other than-1._XOPEN_STREAMSโ supports the XSI STREAMS Option Group ๐._XOPEN_UNIXโ supports the XSI option ๐._XOPEN_UUCPโ supports the UUCP Utilities option ๐ . If it's defined in<unistd.h>, it shall be defined to be-1,0, or200809L. The value of this symbol reported bysysconf()shall be either-1or200809L.
โจ Execution-Time Symbolic Constants โจ
ok so here's the tea bestie, and it's actually important โ:
If any of these following symbolic constants are not defined in the <unistd.h> header, the value shall vary depending on the file to which it is applied. If they are defined, they shall have values suitable for use in #if preprocessing directives.
If any of them are defined to have the value -1 in the <unistd.h> header, the implementation shall not provide the option on any file ๐ซ. If any are defined to have a value other than -1 in the <unistd.h> header, the implementation shall provide the option on all applicable files โ
.
And listen โ all of the following values, whether they're defined as symbolic constants in <unistd.h> or not, may be queried with respect to a specific file using the pathconf() or fpathconf() functions ๐โจ. so you can just ask about one specific file, cute.
_POSIX_ASYNC_IOโ asynchronous input or output operations may be performed for the associated file โก๐.
_POSIX_PRIO_IOโ prioritized input or output operations may be performed for the associated file. ๐ฅ_POSIX_SYNC_IOโ synchronized input or output operations may be performed for the associated file. โจ
Okay so if the following symbolic constants are defined in the <unistd.h> header, bestie, they apply to files and all paths in all file systems on the implementation:
_POSIX_TIMESTAMP_RESOLUTIONโ the resolution, in nanoseconds, for all file timestamps. โฑ๏ธ_POSIX2_SYMLINKSโ symbolic links can be created. ๐ฆ
๐ Constants for Functions ๐
The <unistd.h> header shall define NULL as described in <stddef.h>. periodt.
The <unistd.h> header shall define the following symbolic constants for use with the access() function. The values shall be suitable for use in #if preprocessing directives. (yes, fr fr, they're #if-ready ๐
)
F_OKโ test for existence of file. ๐R_OKโ test for read permission. ๐W_OKโ test for write permission. โ๏ธX_OKโ test for execute (search) permission. ๐
The constants F_OK, R_OK, W_OK, and X_OK and the expressions R_OK|W_OK, R_OK|X_OK, and R_OK|W_OK|X_OK shall all have distinct values. no overlap, no cap.
The <unistd.h> header shall define the following symbolic constants for the confstr() function:
_CS_PATHโ this is the value for thePATHenvironment variable that finds all of the standard utilities that are provided in a manner accessible via theexecfamily of functions. ๐ฃ๏ธ_CS_POSIX_V7_ILP32_OFF32_CFLAGSโ ifsysconf(_SC_V7_ILP32_OFF32)returns-1, the meaning of this value is unspecified. Otherwise, this value is the set of initial options to be given to thec99utility to build an application using a programming model with 32-bitint,long, pointer, andoff_ttypes._CS_POSIX_V7_ILP32_OFF32_LDFLAGSโ ifsysconf(_SC_V7_ILP32_OFF32)returns-1, the meaning of this value is unspecified. Otherwise, this value is the set of final options to be given to thec99utility to build an application using a programming model with 32-bitint,long, pointer, andoff_ttypes._CS_POSIX_V7_ILP32_OFF32_LIBSโ ifsysconf(_SC_V7_ILP32_OFF32)returns-1, the meaning of this value is unspecified. Otherwise, this value is the set of libraries to be given to thec99utility to build an application using a programming model with 32-bitint,long, pointer, andoff_ttypes._CS_POSIX_V7_ILP32_OFFBIG_CFLAGSโ ifsysconf(_SC_V7_ILP32_OFFBIG)returns-1, the meaning of this value is unspecified. Otherwise, this value is the set of initial options to be given to thec99utility to build an application using a programming model with 32-bitint,long, and pointer types, and anoff_ttype using at least 64 bits._CS_POSIX_V7_ILP32_OFFBIG_LDFLAGSโ ifsysconf(_SC_V7_ILP32_OFFBIG)returns-1, the meaning of this value is unspecified. Otherwise, this value is the set of final options to be given to thec99utility to build an application using a programming model with 32-bitint,long, and pointer types, and anoff_ttype using at least 64 bits._CS_POSIX_V7_ILP32_OFFBIG_LIBSโ ifsysconf(_SC_V7_ILP32_OFFBIG)returns-1, the meaning of this value is unspecified. Otherwise, this value is the set of libraries to be given to thec99utility to build an application using a programming model with 32-bitint,long, and pointer types, and anoff_ttype using at least 64 bits._CS_POSIX_V7_LP64_OFF64_CFLAGSโ ifsysconf(_SC_V7_LP64_OFF64)returns-1, the meaning of this value is unspecified. Otherwise, this value is the set of initial options to be given to thec99utility to build an application using a programming model with 32-bitintand 64-bitlong, pointer, andoff_ttypes._CS_POSIX_V7_LP64_OFF64_LDFLAGSโ ifsysconf(_SC_V7_LP64_OFF64)returns-1, the meaning of this value is unspecified. Otherwise, this value is the set of final options to be given to thec99utility to build an application using a programming model with 32-bitintand 64-bitlong, pointer, andoff_ttypes._CS_POSIX_V7_LP64_OFF64_LIBSโ ifsysconf(_SC_V7_LP64_OFF64)returns-1, the meaning of this value is unspecified. Otherwise, this value is the set of libraries to be given to thec99utility to build an application using a programming model with 32-bitintand 64-bitlong, pointer, andoff_ttypes._CS_POSIX_V7_LPBIG_OFFBIG_CFLAGSโ ifsysconf(_SC_V7_LPBIG_OFFBIG)returns-1, the meaning of this value is unspecified. Otherwise, this value is the set of initial options to be given to thec99utility to build an application using a programming model with aninttype using at least 32 bits andlong, pointer, andoff_ttypes using at least 64 bits._CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGSโ ifsysconf(_SC_V7_LPBIG_OFFBIG)returns-1, the meaning of this value is unspecified. Otherwise, this value is the set of final options to be given to thec99utility to build an application using a programming model with aninttype using at least 32 bits andlong, pointer, andoff_ttypes using at least 64 bits._CS_POSIX_V7_LPBIG_OFFBIG_LIBSโ ifsysconf(_SC_V7_LPBIG_OFFBIG)returns-1, the meaning of this value is unspecified. Otherwise, this value is the set of libraries to be given to thec99utility to build an application using a programming model with aninttype using at least 32 bits andlong, pointer, andoff_ttypes using at least 64 bits._CS_POSIX_V7_THREADS_CFLAGSโ ifsysconf(_SC_POSIX_THREADS)returns-1, the meaning of this value is unspecified. Otherwise, this value is the set of initial options to be given to thec99utility to build a multi-threaded application. These flags are in addition to those associated with any of the other_CS_POSIX_V7_*_CFLAGSvalues used to specify particular type size programing environments. ๐งต_CS_POSIX_V7_THREADS_LDFLAGSโ ifsysconf(_SC_POSIX_THREADS)returns-1, the meaning of this value is unspecified. Otherwise, this value is the set of final options to be given to thec99utility to build a multi-threaded application. These flags are in addition to those associated with any of the other_CS_POSIX_V7_*_LDFLAGSvalues used to specify particular type size programing environments. ๐งต_CS_POSIX_V7_WIDTH_RESTRICTED_ENVSโ this value is a<newline>-separated list of names of programming environments supported by the implementation in which the widths of theblksize_t,cc_t,mode_t,nfds_t,pid_t,ptrdiff_t,size_t,speed_t,ssize_t,suseconds_t,tcflag_t,wchar_t, andwint_ttypes are no greater than the width of typelong. The format of each name shall be suitable for use with thegetconf -voption. ๐_CS_V7_ENVโ this is the value that provides the environment variable information (other than that provided by_CS_PATH) that is required by the implementation to create a conforming environment, as described in the implementation's conformance documentation.
The following symbolic constants are reserved for compatibility with Issue 6 (vintage, but iconic ๐):
_CS_POSIX_V6_ILP32_OFF32_CFLAGS_CS_POSIX_V6_ILP32_OFF32_LDFLAGS_CS_POSIX_V6_ILP32_OFF32_LIBS_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS_CS_POSIX_V6_ILP32_OFFBIG_LIBS_CS_POSIX_V6_LP64_OFF64_CFLAGS_CS_POSIX_V6_LP64_OFF64_LDFLAGS_CS_POSIX_V6_LP64_OFF64_LIBS_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS_CS_POSIX_V6_LPBIG_OFFBIG_LIBS_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS_CS_V6_ENV
The <unistd.h> header shall define SEEK_CUR, SEEK_END, and SEEK_SET as described in <stdio.h>. ๐ฏ
The <unistd.h> header shall define the following symbolic constants as possible values for the function argument to the lockf() function:
F_LOCKโ lock a section for exclusive use. ๐F_TESTโ test section for locks by other processes. ๐ต๏ธF_TLOCKโ test and lock a section for exclusive use. ๐F_ULOCKโ unlock locked sections. ๐
The <unistd.h> header shall define the following symbolic constants for pathconf():
_PC_2_SYMLINKS_PC_ALLOC_SIZE_MIN_PC_ASYNC_IO_PC_CHOWN_RESTRICTED_PC_FILESIZEBITS_PC_LINK_MAX_PC_MAX_CANON_PC_MAX_INPUT_PC_NAME_MAX_PC_NO_TRUNC_PC_PATH_MAX_PC_PIPE_BUF_PC_PRIO_IO_PC_REC_INCR_XFER_SIZE_PC_REC_MAX_XFER_SIZE_PC_REC_MIN_XFER_SIZE_PC_REC_XFER_ALIGN_PC_SYMLINK_MAX_PC_SYNC_IO_PC_TIMESTAMP_RESOLUTION_PC_VDISABLE
The <unistd.h> header shall define the following symbolic constants for sysconf():
_SC_2_C_BINDโ the C bind one, first of the_2_crew ๐_SC_2_C_DEVโ C dev, still rolling with the_2_crew_SC_2_CHAR_TERMโ char term, she's here ๐_SC_2_FORT_DEVโ fortran dev, a legacy icon fr_SC_2_FORT_RUNโ fortran run, her sister_SC_2_LOCALEDEFโ localedef, obsessed_SC_2_PBSโ PBS, yes bestie, that PBS_SC_2_PBS_ACCOUNTINGโ PBS accounting ๐ธ_SC_2_PBS_CHECKPOINTโ PBS checkpoint_SC_2_PBS_LOCATEโ PBS locate_SC_2_PBS_MESSAGEโ PBS message_SC_2_PBS_TRACKโ PBS track_SC_2_SW_DEVโ SW dev, slay_SC_2_UPEโ UPE_SC_2_VERSIONโ version, last of the_2_gang โจ_SC_ADVISORY_INFOโ advisory info_SC_AIO_LISTIO_MAXโ AIO listio max_SC_AIO_MAXโ AIO max_SC_AIO_PRIO_DELTA_MAXโ AIO prio delta max_SC_ARG_MAXโ arg max ๐_SC_ASYNCHRONOUS_IOโ asynchronous I/O_SC_ATEXIT_MAXโ atexit max_SC_BARRIERSโ barriers_SC_BC_BASE_MAXโ bc base max_SC_BC_DIM_MAXโ bc dim max_SC_BC_SCALE_MAXโ bc scale max_SC_BC_STRING_MAXโ bc string max_SC_CHILD_MAXโ child max_SC_CLK_TCKโ clk tck, the classic_SC_CLOCK_SELECTIONโ clock selection_SC_COLL_WEIGHTS_MAXโ coll weights max_SC_CPUTIMEโ cputime โฑ๏ธ_SC_DELAYTIMER_MAXโ delaytimer max_SC_EXPR_NEST_MAXโ expr nest max_SC_FSYNCโ fsync, we know her_SC_GETGR_R_SIZE_MAXโ getgr_r size max_SC_GETPW_R_SIZE_MAXโ getpw_r size max_SC_HOST_NAME_MAXโ host name max ๐ฆ_SC_IOV_MAXโ iov max_SC_IPV6โ IPv6, periodt_SC_JOB_CONTROLโ job control_SC_LINE_MAXโ line max_SC_LOGIN_NAME_MAXโ login name max_SC_MAPPED_FILESโ mapped files_SC_MEMLOCKโ memlock_SC_MEMLOCK_RANGEโ memlock range_SC_MEMORY_PROTECTIONโ memory protection ๐ซถ_SC_MESSAGE_PASSINGโ message passing_SC_MONOTONIC_CLOCKโ monotonic clock_SC_MQ_OPEN_MAXโ mq open max_SC_MQ_PRIO_MAXโ mq prio max_SC_NGROUPS_MAXโ ngroups max_SC_OPEN_MAXโ open max_SC_PAGE_SIZEโ page size ๐_SC_PAGESIZEโ pagesize, her twin ๐_SC_PRIORITIZED_IOโ prioritized I/O_SC_PRIORITY_SCHEDULINGโ priority scheduling_SC_RAW_SOCKETSโ raw sockets_SC_RE_DUP_MAXโ re dup max_SC_READER_WRITER_LOCKSโ reader writer locks_SC_REALTIME_SIGNALSโ realtime signals_SC_REGEXPโ regexp ๐_SC_RTSIG_MAXโ rtsig max_SC_SAVED_IDSโ saved ids_SC_SEM_NSEMS_MAXโ sem nsems max_SC_SEM_VALUE_MAXโ sem value max_SC_SEMAPHORESโ semaphores_SC_SHARED_MEMORY_OBJECTSโ shared memory objects_SC_SHELLโ shell ๐_SC_SIGQUEUE_MAXโ sigqueue max_SC_SPAWNโ spawn_SC_SPIN_LOCKSโ spin locks_SC_SPORADIC_SERVERโ sporadic server_SC_SS_REPL_MAXโ ss repl max_SC_STREAM_MAXโ stream max_SC_SYMLOOP_MAXโ symloop max_SC_SYNCHRONIZED_IOโ synchronized I/O_SC_THREAD_ATTR_STACKADDRโ thread attr stackaddr_SC_THREAD_ATTR_STACKSIZEโ thread attr stacksize_SC_THREAD_CPUTIMEโ thread cputime_SC_THREAD_DESTRUCTOR_ITERATIONSโ thread destructor iterations_SC_THREAD_KEYS_MAXโ thread keys max_SC_THREAD_PRIO_INHERITโ thread prio inherit_SC_THREAD_PRIO_PROTECTโ thread prio protect_SC_THREAD_PRIORITY_SCHEDULINGโ thread priority scheduling_SC_THREAD_PROCESS_SHAREDโ thread process shared_SC_THREAD_ROBUST_PRIO_INHERITโ thread robust prio inherit_SC_THREAD_ROBUST_PRIO_PROTECTโ thread robust prio protect_SC_THREAD_SAFE_FUNCTIONSโ thread safe functions_SC_THREAD_SPORADIC_SERVERโ thread sporadic server_SC_THREAD_STACK_MINโ thread stack min_SC_THREAD_THREADS_MAXโ thread threads max_SC_THREADSโ threads ๐งต_SC_TIMEOUTSโ timeouts_SC_TIMER_MAXโ timer max_SC_TIMERSโ timers_SC_TRACEโ trace_SC_TRACE_EVENT_FILTERโ trace event filter_SC_TRACE_EVENT_NAME_MAXโ trace event name max_SC_TRACE_INHERITโ trace inherit_SC_TRACE_LOGโ trace log_SC_TRACE_NAME_MAXโ trace name max_SC_TRACE_SYS_MAXโ trace sys max_SC_TRACE_USER_EVENT_MAXโ trace user event max_SC_TTY_NAME_MAXโ tty name max_SC_TYPED_MEMORY_OBJECTSโ typed memory objects_SC_TZNAME_MAXโ tzname max_SC_V7_ILP32_OFF32โ v7 ilp32 off32_SC_V7_ILP32_OFFBIGโ v7 ilp32 offbig_SC_V7_LP64_OFF64โ v7 lp64 off64_SC_V7_LPBIG_OFFBIGโ v7 lpbig offbig_SC_V6_ILP32_OFF32โ v6 ilp32 off32_SC_V6_ILP32_OFFBIGโ v6 ilp32 offbig_SC_V6_LP64_OFF64โ v6 lp64 off64_SC_V6_LPBIG_OFFBIGโ v6 lpbig offbig_SC_VERSIONโ version โญ_SC_XOPEN_CRYPTโ xopen crypt_SC_XOPEN_ENH_I18Nโ xopen enh i18n_SC_XOPEN_REALTIMEโ xopen realtime_SC_XOPEN_REALTIME_THREADSโ xopen realtime threads_SC_XOPEN_SHMโ xopen shm_SC_XOPEN_STREAMSโ xopen streams_SC_XOPEN_UNIXโ xopen unix_SC_XOPEN_UUCPโ xopen uucp_SC_XOPEN_VERSIONโ xopen version โจ
The two constants _SC_PAGESIZE and _SC_PAGE_SIZE may be defined to have the same value. (twins!! ๐
)
The <unistd.h> header shall define the following symbolic constants for file streams:
STDERR_FILENOโ file number of stderr;2. the messy one ๐ญSTDIN_FILENOโ file number of stdin;0. the listener ๐ซถSTDOUT_FILENOโ file number of stdout;1. the performer โจ
And the <unistd.h> header shall define the following symbolic constant for terminal special character handling:
_POSIX_VDISABLEโ this symbol shall be defined to be the value of a character that shall disable terminal special character handling as described in Section 11.2.6, Special Control Characters. This symbol shall always be set to a value other than-1. no cap, always not-1๐
๐ Type Definitions ๐
The <unistd.h> header shall define the size_t, ssize_t, uid_t, gid_t, off_t, and pid_t types as described in <sys/types.h>.
The <unistd.h> header shall define the intptr_t type as described in <stdint.h>.
๐ Declarations ๐
The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.
int access(const char *, int);
unsigned alarm(unsigned);
int chdir(const char *);
int chown(const char *, uid_t, gid_t);
int close(int);
size_t confstr(int, char *, size_t);
char *crypt(const char *, const char *);
int dup(int);
int dup2(int, int);
void _exit(int);
void encrypt(char [64], int);
int execl(const char *, const char *, ...);
int execle(const char *, const char *, ...);
int execlp(const char *, const char *, ...);
int execv(const char *, char *const []);
int execve(const char *, char *const [], char *const []);
int execvp(const char *, char *const []);
int faccessat(int, const char *, int, int);
int fchdir(int);
int fchown(int, uid_t, gid_t);
int fchownat(int, const char *, uid_t, gid_t, int);
int fdatasync(int);
int fexecve(int, char *const [], char *const []);
pid_t fork(void);
long fpathconf(int, int);
int fsync(int);
int ftruncate(int, off_t);
char *getcwd(char *, size_t);
gid_t getegid(void);
uid_t geteuid(void);
gid_t getgid(void);
int getgroups(int, gid_t []);
long gethostid(void);
int gethostname(char *, size_t);
char *getlogin(void);
int getlogin_r(char *, size_t);
int getopt(int, char * const [], const char *);
pid_t getpgid(pid_t);
pid_t getpgrp(void);
pid_t getpid(void);
pid_t getppid(void);
pid_t getsid(pid_t);
uid_t getuid(void);
int isatty(int);
int lchown(const char *, uid_t, gid_t);
int link(const char *, const char *);
int linkat(int, const char *, int, const char *, int);
int lockf(int, int, off_t);
off_t lseek(int, off_t, int);
int nice(int);
long pathconf(const char *, int);
int pause(void);
int pipe(int [2]);
ssize_t pread(int, void *, size_t, off_t);
ssize_t pwrite(int, const void *, size_t, off_t);
ssize_t read(int, void *, size_t);
ssize_t readlink(const char *restrict, char *restrict, size_t);
ssize_t readlinkat(int, const char *restrict, char *restrict, size_t);
int rmdir(const char *);
int setegid(gid_t);
int seteuid(uid_t);
int setgid(gid_t);
int setpgid(pid_t, pid_t);
pid_t setpgrp(void);
int setregid(gid_t, gid_t);
int setreuid(uid_t, uid_t);
pid_t setsid(void);
int setuid(uid_t);
unsigned sleep(unsigned);
void swab(const void *restrict, void *restrict, ssize_t);
int symlink(const char *, const char *);
int symlinkat(const char *, int, const char *);
void sync(void);
long sysconf(int);
pid_t tcgetpgrp(int);
int tcsetpgrp(int, pid_t);
int truncate(const char *, off_t);
char *ttyname(int);
int ttyname_r(int, char *, size_t);
int unlink(const char *);
int unlinkat(int, const char *, int);
ssize_t write(int, const void *, size_t);
Implementations may also include the pthread_atfork() prototype as defined in <pthread.h>. Implementations may also include the ctermid() prototype as defined in <stdio.h>.
The <unistd.h> header shall declare the following external variables:
extern char *optarg;
extern int opterr, optind, optopt;
Inclusion of the <unistd.h> header may make visible all symbols from the headers <stddef.h>, <stdint.h>, and <stdio.h>.
The following sections are informative.
๐ APPLICATION USAGE ๐
okay so real talk: POSIX.1โ2008 only describes the behavior of systems that claim conformance to it. That's it, that's the deal.
But โ and this is the part that's actually useful โ application developers who want to write applications that adapt to other versions of this standard (or to systems that do not conform to any POSIX standard at all) may find it useful to code them so as to conditionally compile different code depending on the value of _POSIX_VERSION. For example:
#if _POSIX_VERSION >= 200112L
/* Use the newer function that copes with large files. */
off_t pos=ftello(fp);
#else
/* Either this is an old version of POSIX, or _POSIX_VERSION is
not even defined, so use the traditional function. */
long pos=ftell(fp);
#endif
Earlier versions of POSIX.1โ2008 and of the Single UNIX Specification can be identified by the following macros:
- POSIX.1โ1988 standard โ
_POSIX_VERSION==198808L - POSIX.1โ1990 standard โ
_POSIX_VERSION==199009L - ISO POSIXโ1:1996 standard โ
_POSIX_VERSION==199506L - Single UNIX Specification, Version 1 โ
_XOPEN_UNIXand_XOPEN_VERSION==4 - Single UNIX Specification, Version 2 โ
_XOPEN_UNIXand_XOPEN_VERSION==500 - ISO POSIXโ1:2001 and Single UNIX Specification, Version 3 โ
_POSIX_VERSION==200112L, plus (if the XSI option is supported)_XOPEN_UNIXand_XOPEN_VERSION==600
POSIX.1โ2008 does not make any attempt to define application binary interaction with the underlying operating system. bestie, it just doesn't, it's not that kind of document ๐
However, application developers may find it useful to query _SC_VERSION at runtime via sysconf() to determine whether the current version of the operating system supports the necessary functionality, as in the following program fragment:
if (sysconf(_SC_VERSION) < 200809L) {
fprintf(stderr, "POSIX.1-2008 system required, terminating \n");
exit(1);
}
New applications should not use_XOPEN_SHMor_XOPEN_ENH_I18N. likeโฆ just don't, okay? ๐
๐ง RATIONALE (aka the "why is it Like This" section)
okay bestie so as POSIX.1โ2008 kept evolving, some options got standardized enough that the standard developers were like "honestly, just requiring one of the option choices is simpler than keeping the whole option around." but for backwards-compatibility? the option flags (with their required constant values) stayed. periodt. ๐
๐ Version Test Macros
so the standard developers were this close to changing the definition of _POSIX_VERSION and yeeting _SC_VERSION out of the sysconf() spec, because ngl some of them thought the utility to an application was pretty minimal, and implementing the functionality is potentially problematic. ๐ but then they remembered: support for existing application binaries is a whole thing for manufacturers, application developers, and users of implementations conforming to POSIX.1โ2008. so they kept it.
and like, sure, the example using _SC_VERSION in the APPLICATION USAGE section doesn't give you the greatest degree of imaginable utility as an application developer or user, but it's arguably better than a core file or some other equally obscure result. (also possible: implementations can encode and recognize application binaries compiled in various POSIX.1-conforming environments, and modify the semantics of the underlying system to conform to what the application expects. iconic behavior honestly.) so for all the reasons above and in APPLICATION USAGE, the standard developers elected to retain the _POSIX_VERSION and _SC_VERSION functionality. ๐
๐งฉ Compile-Time Symbolic Constants for System-Wide Options
POSIX.1โ2008 includes support in certain areas for the newly adopted policy governing options and stubs. โจ
this policy gives implementations flexibility in how they support options, and it also spells out how conforming applications can adapt to different implementations that support different sets of options. it allows the following:
- if an implementation has zero interest in supporting an option, it doesn't have to provide anything associated with that option beyond the announcement that it does not support it.
- an implementation can support a partial or incompatible version of an option (as a non-standard extension) as long as it does not claim to support the option.
- an application can determine whether the option is supported. a strictly conforming application must check this announcement mechanism before first using anything associated with the option.
โ ๏ธ there's an important implication of this policy, bestie, and you need to hear it: POSIX.1โ2008 cannot dictate the behavior of interfaces associated with an option when the implementation does not claim to support the option. in particular, it cannot require that a function associated with an unsupported option will fail if it does not perform as specified.
however, this policy does not prevent a standard from requiring certain functions to always be present, but that they shall always fail on some implementations. the setpgid() function in the POSIX.1โ1990 standard, for example, is considered appropriate. ๐
the POSIX standards include various options, and the C-language binding support for an option implies that the implementation must supply data types and function interfaces. an application must be able to discover whether the implementation supports each option.
any application must consider the following three cases for each option:
- Option never supported.
the implementation advertises at compile time that the option will never be supported. in this case, it is not necessary for the implementation to supply any of the data types or function interfaces that are provided only as part of the option. the implementation might provide data types and functions that are similar to those defined by POSIX.1โ2008, but there is no guarantee for any particular behavior. ๐
- Option always supported.
the implementation advertises at compile time that the option will always be supported. in this case, all data types and function interfaces shall be available and shall operate as specified. slay. โจ
- Option might or might not be supported.
some implementations might not provide a mechanism to specify support of options at compile time. in addition, the implementation might be unable or unwilling to specify support or non-support at compile time. in either case, any application that might use the option at runtime must be able to compile and execute. the implementation must provide, at compile time, all data types and function interfaces that are necessary to allow this. in this situation, there must be a mechanism that allows the application to query, at runtime, whether the option is supported. if the application attempts to use the option when it is not supported, the result is unspecified unless explicitly specified otherwise in POSIX.1โ2008. ๐
๐ฎ FUTURE DIRECTIONS
None.
(yeah. nothing. the future is... quiet. ๐ธ)
๐ SEE ALSO
the header besties you gotta go visit:
<limits.h><stddef.h><stdint.h><stdio.h><sys_socket.h><sys_types.h><termios.h><wctype.h>
and from the System Interfaces volume of POSIX.1โ2017, the whole function friend group:
access(), alarm(), chown(), close(), confstr(), crypt(), ctermid(), dup(), _Exit(), encrypt(), exec, fchdir(), fchown(), fdatasync(), fork(), fpathconf(), fsync(), ftruncate(), getcwd(), getegid(), geteuid(), getgid(), getgroups(), gethostid(), gethostname(), getlogin(), getopt(), getpgid(), getpgrp(), getpid(), getppid(), getsid(), getuid(), isatty(), lchown(), link(), lockf(), lseek(), nice(), pause(), pipe(), read(), readlink(), rmdir(), setegid(), seteuid(), setgid(), setpgid(), setpgrp(), setregid(), setreuid(), setsid(), setuid(), sleep(), swab(), symlink(), sync(), sysconf(), tcgetpgrp(), tcsetpgrp(), truncate(), ttyname(), unlink(), write()
โ๏ธ 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 .
and that's a wrap on the whole page, bestie!! ๐ this one's from IEEE/The Open Group, dated 2017, and it's the one and only unistd.h(0P) โ go forth and check your feature test macros before you use anything, i'm literally begging. ๐โจ๐ฆ no cap. ๐
๐ฆ 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