1 .\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
2 .TH "<unistd.h>" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
5 unistd.h \- standard symbolic constants and types
8 \fB#include <unistd.h>\fP
11 The \fI<unistd.h>\fP header defines miscellaneous symbolic constants
12 and types, and declares miscellaneous functions. The
13 actual values of the constants are unspecified except as shown. The
14 contents of this header are shown below.
15 .SS Version Test Macros
17 The following symbolic constants shall be defined:
20 Integer value indicating version of IEEE\ Std\ 1003.1 (C-language
21 binding) to which the implementation conforms. For
22 implementations conforming to IEEE\ Std\ 1003.1-2001, the value shall
26 Integer value indicating version of the Shell and Utilities volume
27 of IEEE\ Std\ 1003.1 to which the implementation
28 conforms. For implementations conforming to IEEE\ Std\ 1003.1-2001,
29 the value shall be 200112L.
32 The following symbolic constant shall be defined only if the implementation
33 supports the XSI option; see \fIXSI Conformance\fP .
37 Integer value indicating version of the X/Open Portability Guide to
38 which the implementation conforms. The value shall be 600.
40 .SS Constants for Options and Option Groups
42 The following symbolic constants, if defined in \fI<unistd.h>\fP,
43 shall have a value of -1, 0, or greater, unless
44 otherwise specified below. If these are undefined, the \fIfpathconf\fP(),
45 \fIpathconf\fP(), or \fIsysconf\fP() functions can be
46 used to determine whether the option is provided for a particular
47 invocation of the application.
49 If a symbolic constant is defined with the value -1, the option is
50 not supported. Headers, data types, and function interfaces
51 required only for the option need not be supplied. An application
52 that attempts to use anything associated only with the option is
53 considered to be requiring an extension.
55 If a symbolic constant is defined with a value greater than zero,
56 the option shall always be supported when the application is
57 executed. All headers, data types, and functions shall be present
58 and shall operate as specified.
60 If a symbolic constant is defined with the value zero, all headers,
61 data types, and functions shall be present. The application
62 can check at runtime to see whether the option is supported by calling
63 \fIfpathconf\fP(), \fIpathconf\fP(), or \fIsysconf\fP() with the indicated
66 Unless explicitly specified otherwise, the behavior of functions associated
67 with an unsupported option is unspecified, and an
68 application that uses such functions without first checking \fIfpathconf\fP(),
69 \fIpathconf\fP(), or \fIsysconf\fP() is considered to be
70 requiring an extension.
72 For conformance requirements, refer to \fIConformance\fP .
76 The implementation supports the Advisory Information option. If this
77 symbol has a value other than -1 or 0, it shall have the value
80 _POSIX_ASYNCHRONOUS_IO
82 The implementation supports the Asynchronous Input and Output option.
83 If this symbol has a value other than -1 or 0, it shall have
88 The implementation supports the Barriers option. If this symbol has
89 a value other than -1 or 0, it shall have the value 200112L.
91 _POSIX_CHOWN_RESTRICTED
92 The use of \fIchown\fP() and \fIfchown\fP() is
93 restricted to a process with appropriate privileges, and to changing
94 the group ID of a file only to the effective group ID of the
95 process or to one of its supplementary group IDs. This symbol shall
96 always be set to a value other than -1.
98 _POSIX_CLOCK_SELECTION
100 The implementation supports the Clock Selection option. If this symbol
101 has a value other than -1 or 0, it shall have the value
106 The implementation supports the Process CPU-Time Clocks option. If
107 this symbol has a value other than -1 or 0, it shall have the
112 The implementation supports the File Synchronization option. If this
113 symbol has a value other than -1 or 0, it shall have the value
117 The implementation supports the IPv6 option. If this symbol has a
118 value other than -1 or 0, it shall have the value 200112L.
121 The implementation supports job control. This symbol shall always
122 be set to a value greater than zero.
126 The implementation supports the Memory Mapped Files option. If this
127 symbol has a value other than -1 or 0, it shall have the value
132 The implementation supports the Process Memory Locking option. If
133 this symbol has a value other than -1 or 0, it shall have the
138 The implementation supports the Range Memory Locking option. If this
139 symbol has a value other than -1 or 0, it shall have the value
142 _POSIX_MEMORY_PROTECTION
144 The implementation supports the Memory Protection option. If this
145 symbol has a value other than -1 or 0, it shall have the value
148 _POSIX_MESSAGE_PASSING
150 The implementation supports the Message Passing option. If this symbol
151 has a value other than -1 or 0, it shall have the value
154 _POSIX_MONOTONIC_CLOCK
156 The implementation supports the Monotonic Clock option. If this symbol
157 has a value other than -1 or 0, it shall have the value
161 Pathname components longer than {NAME_MAX} generate an error. This
162 symbol shall always be set to a value other than -1.
164 _POSIX_PRIORITIZED_IO
166 The implementation supports the Prioritized Input and Output option.
167 If this symbol has a value other than -1 or 0, it shall have
170 _POSIX_PRIORITY_SCHEDULING
172 The implementation supports the Process Scheduling option. If this
173 symbol has a value other than -1 or 0, it shall have the value
178 The implementation supports the Raw Sockets option. If this symbol
179 has a value other than -1 or 0, it shall have the value 200112L.
181 _POSIX_READER_WRITER_LOCKS
183 The implementation supports the Read-Write Locks option. This is always
184 set to a value greater than zero if the Threads option is
185 supported. If this symbol has a value other than -1 or 0, it shall
186 have the value 200112L.
188 _POSIX_REALTIME_SIGNALS
190 The implementation supports the Realtime Signals Extension option.
191 If this symbol has a value other than -1 or 0, it shall have the
195 The implementation supports the Regular Expression Handling option.
196 This symbol shall always be set to a value greater than
200 Each process has a saved set-user-ID and a saved set-group-ID. This
201 symbol shall always be set to a value greater than zero.
205 The implementation supports the Semaphores option. If this symbol
206 has a value other than -1 or 0, it shall have the value 200112L.
208 _POSIX_SHARED_MEMORY_OBJECTS
210 The implementation supports the Shared Memory Objects option. If this
211 symbol has a value other than -1 or 0, it shall have the
215 The implementation supports the POSIX shell. This symbol shall always
216 be set to a value greater than zero.
220 The implementation supports the Spawn option. If this symbol has a
221 value other than -1 or 0, it shall have the value 200112L.
225 The implementation supports the Spin Locks option. If this symbol
226 has a value other than -1 or 0, it shall have the value 200112L.
228 _POSIX_SPORADIC_SERVER
230 The implementation supports the Process Sporadic Server option. If
231 this symbol has a value other than -1 or 0, it shall have the
234 _POSIX_SYNCHRONIZED_IO
236 The implementation supports the Synchronized Input and Output option.
237 If this symbol has a value other than -1 or 0, it shall have
240 _POSIX_THREAD_ATTR_STACKADDR
242 The implementation supports the Thread Stack Address Attribute option.
243 If this symbol has a value other than -1 or 0, it shall have
246 _POSIX_THREAD_ATTR_STACKSIZE
248 The implementation supports the Thread Stack Size Attribute option.
249 If this symbol has a value other than -1 or 0, it shall have
252 _POSIX_THREAD_CPUTIME
254 The implementation supports the Thread CPU-Time Clocks option. If
255 this symbol has a value other than -1 or 0, it shall have the
258 _POSIX_THREAD_PRIO_INHERIT
260 The implementation supports the Thread Priority Inheritance option.
261 If this symbol has a value other than -1 or 0, it shall have
264 _POSIX_THREAD_PRIO_PROTECT
266 The implementation supports the Thread Priority Protection option.
267 If this symbol has a value other than -1 or 0, it shall have the
270 _POSIX_THREAD_PRIORITY_SCHEDULING
272 The implementation supports the Thread Execution Scheduling option.
273 If this symbol has a value other than -1 or 0, it shall have
276 _POSIX_THREAD_PROCESS_SHARED
278 The implementation supports the Thread Process-Shared Synchronization
279 option. If this symbol has a value other than -1 or 0, it
280 shall have the value 200112L.
282 _POSIX_THREAD_SAFE_FUNCTIONS
284 The implementation supports the Thread-Safe Functions option. If this
285 symbol has a value other than -1 or 0, it shall have the
288 _POSIX_THREAD_SPORADIC_SERVER
290 The implementation supports the Thread Sporadic Server option. If
291 this symbol has a value other than -1 or 0, it shall have the
296 The implementation supports the Threads option. If this symbol has
297 a value other than -1 or 0, it shall have the value 200112L.
301 The implementation supports the Timeouts option. If this symbol has
302 a value other than -1 or 0, it shall have the value 200112L.
306 The implementation supports the Timers option. If this symbol has
307 a value other than -1 or 0, it shall have the value 200112L.
311 The implementation supports the Trace option. If this symbol has a
312 value other than -1 or 0, it shall have the value 200112L.
314 _POSIX_TRACE_EVENT_FILTER
316 The implementation supports the Trace Event Filter option. If this
317 symbol has a value other than -1 or 0, it shall have the value
322 The implementation supports the Trace Inherit option. If this symbol
323 has a value other than -1 or 0, it shall have the value
328 The implementation supports the Trace Log option. If this symbol has
329 a value other than -1 or 0, it shall have the value 200112L.
331 _POSIX_TYPED_MEMORY_OBJECTS
333 The implementation supports the Typed Memory Objects option. If this
334 symbol has a value other than -1 or 0, it shall have the value
338 This symbol shall be defined to be the value of a character that shall
339 disable terminal special character handling as described in
340 \fI<termios.h>\fP . This symbol shall always be set to a value other
344 The implementation supports the C-Language Binding option. This symbol
345 shall always have the value 200112L.
349 The implementation supports the C-Language Development Utilities option.
350 If this symbol has a value other than -1 or 0, it shall
351 have the value 200112L.
354 The implementation supports at least one terminal type.
358 The implementation supports the FORTRAN Development Utilities option.
359 If this symbol has a value other than -1 or 0, it shall have
364 The implementation supports the FORTRAN Runtime Utilities option.
365 If this symbol has a value other than -1 or 0, it shall have the
369 The implementation supports the creation of locales by the \fIlocaledef\fP
371 this symbol has a value other than -1 or 0, it shall have the value
376 The implementation supports the Batch Environment Services and Utilities
377 option. If this symbol has a value other than -1 or 0, it
378 shall have the value 200112L.
380 _POSIX2_PBS_ACCOUNTING
382 The implementation supports the Batch Accounting option. If this symbol
383 has a value other than -1 or 0, it shall have the value
386 _POSIX2_PBS_CHECKPOINT
388 The implementation supports the Batch Checkpoint/Restart option. If
389 this symbol has a value other than -1 or 0, it shall have the
394 The implementation supports the Locate Batch Job Request option. If
395 this symbol has a value other than -1 or 0, it shall have the
400 The implementation supports the Batch Job Message Request option.
401 If this symbol has a value other than -1 or 0, it shall have the
406 The implementation supports the Track Batch Job Request option. If
407 this symbol has a value other than -1 or 0, it shall have the
412 The implementation supports the Software Development Utilities option.
413 If this symbol has a value other than -1 or 0, it shall have
418 The implementation supports the User Portability Utilities option.
419 If this symbol has a value other than -1 or 0, it shall have the
423 The implementation provides a C-language compilation environment with
424 32-bit \fBint\fP, \fBlong\fP, \fBpointer\fP, and
428 The implementation provides a C-language compilation environment with
429 32-bit \fBint\fP, \fBlong\fP, and \fBpointer\fP types and
430 an \fBoff_t\fP type using at least 64 bits.
433 The implementation provides a C-language compilation environment with
434 32-bit \fBint\fP and 64-bit \fBlong\fP, \fBpointer\fP, and
438 The implementation provides a C-language compilation environment with
439 an \fBint\fP type using at least 32 bits and \fBlong\fP,
440 \fBpointer\fP, and \fBoff_t\fP types using at least 64 bits.
442 _XBS5_ILP32_OFF32 (\fBLEGACY\fP)
444 The implementation provides a C-language compilation environment with
445 32-bit \fBint\fP, \fBlong\fP, \fBpointer\fP, and
448 _XBS5_ILP32_OFFBIG (\fBLEGACY\fP)
450 The implementation provides a C-language compilation environment with
451 32-bit \fBint\fP, \fBlong\fP, and \fBpointer\fP types and
452 an \fBoff_t\fP type using at least 64 bits.
454 _XBS5_LP64_OFF64 (\fBLEGACY\fP)
456 The implementation provides a C-language compilation environment with
457 32-bit \fBint\fP and 64-bit \fBlong\fP, \fBpointer\fP, and
460 _XBS5_LPBIG_OFFBIG (\fBLEGACY\fP)
462 The implementation provides a C-language compilation environment with
463 an \fBint\fP type using at least 32 bits and \fBlong\fP,
464 \fBpointer\fP, and \fBoff_t\fP types using at least 64 bits.
468 The implementation supports the X/Open Encryption Option Group.
471 The implementation supports the Issue 4, Version 2 Enhanced Internationalization
472 Option Group. This symbol shall always be set to a
476 The implementation supports the Legacy Option Group.
479 The implementation supports the X/Open Realtime Option Group.
481 _XOPEN_REALTIME_THREADS
482 The implementation supports the X/Open Realtime Threads Option Group.
485 The implementation supports the Issue 4, Version 2 Shared Memory Option
486 Group. This symbol shall always be set to a value other
490 The implementation supports the XSI STREAMS Option Group.
494 The implementation supports the XSI extension.
496 .SS Execution-Time Symbolic Constants
498 If any of the following constants are not defined in the \fI<unistd.h>\fP
499 header, the value shall vary depending on the
500 file to which it is applied.
502 If any of the following constants are defined to have value -1 in
503 the \fI<unistd.h>\fP header, the implementation shall
504 not provide the option on any file; if any are defined to have a value
505 other than -1 in the \fI<unistd.h>\fP header, the
506 implementation shall provide the option on all applicable files.
508 All of the following constants, whether defined in \fI<unistd.h>\fP
509 or not, may be queried with respect to a specific
510 file using the \fIpathconf\fP() or \fIfpathconf\fP() functions:
513 Asynchronous input or output operations may be performed for the associated
517 Prioritized input or output operations may be performed for the associated
521 Synchronized input or output operations may be performed for the associated
524 .SS Constants for Functions
526 The following symbolic constant shall be defined:
532 The following symbolic constants shall be defined for the \fIaccess\fP()
536 Test for existence of file.
539 Test for read permission.
542 Test for write permission.
545 Test for execute (search) permission.
548 The constants F_OK, R_OK, W_OK, and X_OK and the expressions \fIR_OK\fP|\fIW_OK\fP,
549 \fIR_OK\fP|\fIX_OK\fP, and
550 \fIR_OK\fP|\fIW_OK\fP|\fIX_OK\fP shall all have distinct values.
552 The following symbolic constants shall be defined for the \fIconfstr\fP()
556 This is the value for the \fIPATH\fP environment variable that finds
557 all standard utilities.
559 _CS_POSIX_V6_ILP32_OFF32_CFLAGS
560 If \fIsysconf\fP(_SC_V6_ILP32_OFF32) returns -1, the meaning of this
561 value is unspecified. Otherwise, this value is the set of
562 initial options to be given to the \fIc99\fP utility to build an application
564 programming model with 32-bit \fBint\fP, \fBlong\fP, \fBpointer\fP,
565 and \fBoff_t\fP types.
567 _CS_POSIX_V6_ILP32_OFF32_LDFLAGS
568 If \fIsysconf\fP(_SC_V6_ILP32_OFF32) returns -1, the meaning of this
569 value is unspecified. Otherwise, this value is the set of
570 final options to be given to the \fIc99\fP utility to build an application
572 model with 32-bit \fBint\fP, \fBlong\fP, \fBpointer\fP, and \fBoff_t\fP
575 _CS_POSIX_V6_ILP32_OFF32_LIBS
576 If \fIsysconf\fP(_SC_V6_ILP32_OFF32) returns -1, the meaning of this
577 value is unspecified. Otherwise, this value is the set of
578 libraries to be given to the \fIc99\fP utility to build an application
580 model with 32-bit \fBint\fP, \fBlong\fP, \fBpointer\fP, and \fBoff_t\fP
583 _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS
584 If \fIsysconf\fP(_SC_V6_ILP32_OFFBIG) returns -1, the meaning of this
585 value is unspecified. Otherwise, this value is the set of
586 initial options to be given to the \fIc99\fP utility to build an application
588 programming model with 32-bit \fBint\fP, \fBlong\fP, and \fBpointer\fP
589 types, and an \fBoff_t\fP type using at least 64
592 _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS
593 If \fIsysconf\fP(_SC_V6_ILP32_OFFBIG) returns -1, the meaning of this
594 value is unspecified. Otherwise, this value is the set of
595 final options to be given to the \fIc99\fP utility to build an application
597 model with 32-bit \fBint\fP, \fBlong\fP, and \fBpointer\fP types,
598 and an \fBoff_t\fP type using at least 64 bits.
600 _CS_POSIX_V6_ILP32_OFFBIG_LIBS
601 If \fIsysconf\fP(_SC_V6_ILP32_OFFBIG) returns -1, the meaning of this
602 value is unspecified. Otherwise, this value is the set of
603 libraries to be given to the \fIc99\fP utility to build an application
605 model with 32-bit \fBint\fP, \fBlong\fP, and \fBpointer\fP types,
606 and an \fBoff_t\fP type using at least 64 bits.
608 _CS_POSIX_V6_LP64_OFF64_CFLAGS
609 If \fIsysconf\fP(_SC_V6_LP64_OFF64) returns -1, the meaning of this
610 value is unspecified. Otherwise, this value is the set of
611 initial options to be given to the \fIc99\fP utility to build an application
613 programming model with 32-bit \fBint\fP and 64-bit \fBlong\fP, \fBpointer\fP,
614 and \fBoff_t\fP types.
616 _CS_POSIX_V6_LP64_OFF64_LDFLAGS
617 If \fIsysconf\fP(_SC_V6_LP64_OFF64) returns -1, the meaning of this
618 value is unspecified. Otherwise, this value is the set of
619 final options to be given to the \fIc99\fP utility to build an application
621 model with 32-bit \fBint\fP and 64-bit \fBlong\fP, \fBpointer\fP,
622 and \fBoff_t\fP types.
624 _CS_POSIX_V6_LP64_OFF64_LIBS
625 If \fIsysconf\fP(_SC_V6_LP64_OFF64) returns -1, the meaning of this
626 value is unspecified. Otherwise, this value is the set of
627 libraries to be given to the \fIc99\fP utility to build an application
629 model with 32-bit \fBint\fP and 64-bit \fBlong\fP, \fBpointer\fP,
630 and \fBoff_t\fP types.
632 _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS
633 If \fIsysconf\fP(_SC_V6_LPBIG_OFFBIG) returns -1, the meaning of this
634 value is unspecified. Otherwise, this value is the set of
635 initial options to be given to the \fIc99\fP utility to build an application
637 programming model with an \fBint\fP type using at least 32 bits and
638 \fBlong\fP, \fBpointer\fP, and \fBoff_t\fP types using at
641 _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
642 If \fIsysconf\fP(_SC_V6_LPBIG_OFFBIG) returns -1, the meaning of this
643 value is unspecified. Otherwise, this value is the set of
644 final options to be given to the \fIc99\fP utility to build an application
646 model with an \fBint\fP type using at least 32 bits and \fBlong\fP,
647 \fBpointer\fP, and \fBoff_t\fP types using at least 64
650 _CS_POSIX_V6_LPBIG_OFFBIG_LIBS
651 If \fIsysconf\fP(_SC_V6_LPBIG_OFFBIG) returns -1, the meaning of this
652 value is unspecified. Otherwise, this value is the set of
653 libraries to be given to the \fIc99\fP utility to build an application
655 model with an \fBint\fP type using at least 32 bits and \fBlong\fP,
656 \fBpointer\fP, and \fBoff_t\fP types using at least 64
659 _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS
660 This value is a <newline>-separated list of names of programming environments
661 supported by the implementation in which the
662 widths of the \fBblksize_t\fP, \fBcc_t\fP, \fBmode_t\fP, \fBnfds_t\fP,
663 \fBpid_t\fP, \fBptrdiff_t\fP, \fBsize_t\fP,
664 \fBspeed_t\fP, \fBssize_t\fP, \fBsuseconds_t\fP, \fBtcflag_t\fP, \fBuseconds_t\fP,
665 \fBwchar_t\fP, and \fBwint_t\fP types are
666 no greater than the width of type \fBlong\fP.
669 The following symbolic constants are reserved for compatibility with
673 _CS_XBS5_ILP32_OFF32_CFLAGS (\fBLEGACY\fP)
675 _CS_XBS5_ILP32_OFF32_LDFLAGS (\fBLEGACY\fP)
677 _CS_XBS5_ILP32_OFF32_LIBS (\fBLEGACY\fP)
679 _CS_XBS5_ILP32_OFF32_LINTFLAGS (\fBLEGACY\fP)
681 _CS_XBS5_ILP32_OFFBIG_CFLAGS (\fBLEGACY\fP)
683 _CS_XBS5_ILP32_OFFBIG_LDFLAGS (\fBLEGACY\fP)
685 _CS_XBS5_ILP32_OFFBIG_LIBS (\fBLEGACY\fP)
687 _CS_XBS5_ILP32_OFFBIG_LINTFLAGS (\fBLEGACY\fP)
689 _CS_XBS5_LP64_OFF64_CFLAGS (\fBLEGACY\fP)
691 _CS_XBS5_LP64_OFF64_LDFLAGS (\fBLEGACY\fP)
693 _CS_XBS5_LP64_OFF64_LIBS (\fBLEGACY\fP)
695 _CS_XBS5_LP64_OFF64_LINTFLAGS (\fBLEGACY\fP)
697 _CS_XBS5_LPBIG_OFFBIG_CFLAGS (\fBLEGACY\fP)
699 _CS_XBS5_LPBIG_OFFBIG_LDFLAGS (\fBLEGACY\fP)
701 _CS_XBS5_LPBIG_OFFBIG_LIBS (\fBLEGACY\fP)
703 _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS (\fBLEGACY\fP)
707 The following symbolic constants shall be defined for the \fIlseek\fP()
708 and \fIfcntl\fP() functions and shall have distinct values:
711 Set file offset to current plus \fIoffset\fP.
714 Set file offset to EOF plus \fIoffset\fP.
717 Set file offset to \fIoffset\fP.
720 The following symbolic constants shall be defined as possible values
721 for the \fIfunction\fP argument to the \fIlockf\fP() function:
724 Lock a section for exclusive use.
727 Test section for locks by other processes.
730 Test and lock a section for exclusive use.
733 Unlock locked sections.
736 The following symbolic constants shall be defined for \fIpathconf\fP():
763 _PC_REC_INCR_XFER_SIZE
765 _PC_REC_MIN_XFER_SIZE
776 The following symbolic constants shall be defined for \fIsysconf\fP():
819 _SC_AIO_PRIO_DELTA_MAX
875 _SC_MEMORY_PROTECTION
895 _SC_PRIORITY_SCHEDULING
901 _SC_READER_WRITER_LOCKS
917 _SC_SHARED_MEMORY_OBJECTS
935 _SC_THREAD_ATTR_STACKADDR
937 _SC_THREAD_ATTR_STACKSIZE
941 _SC_THREAD_DESTRUCTOR_ITERATIONS
945 _SC_THREAD_PRIO_INHERIT
947 _SC_THREAD_PRIO_PROTECT
949 _SC_THREAD_PRIORITY_SCHEDULING
951 _SC_THREAD_PROCESS_SHARED
953 _SC_THREAD_SAFE_FUNCTIONS
955 _SC_THREAD_SPORADIC_SERVER
959 _SC_THREAD_THREADS_MAX
971 _SC_TRACE_EVENT_FILTER
979 _SC_TYPED_MEMORY_OBJECTS
993 _SC_XBS5_ILP32_OFF32 (\fBLEGACY\fP)
995 _SC_XBS5_ILP32_OFFBIG (\fBLEGACY\fP)
997 _SC_XBS5_LP64_OFF64 (\fBLEGACY\fP)
999 _SC_XBS5_LPBIG_OFFBIG (\fBLEGACY\fP)
1009 _SC_XOPEN_REALTIME_THREADS
1019 _SC_XOPEN_XCU_VERSION
1022 The two constants _SC_PAGESIZE and _SC_PAGE_SIZE may be defined to
1023 have the same value.
1025 The following symbolic constants shall be defined for file streams:
1028 File number of \fIstderr\fP; 2.
1031 File number of \fIstdin\fP; 0.
1034 File number of \fIstdout\fP; 1.
1036 .SS Type Definitions
1038 The \fBsize_t\fP, \fBssize_t\fP, \fBuid_t\fP, \fBgid_t\fP, \fBoff_t\fP,
1039 \fBpid_t\fP, and \fBuseconds_t\fP types shall be
1040 defined as described in \fI<sys/types.h>\fP.
1042 The \fBintptr_t\fP type shall be defined as described in \fI<inttypes.h>\fP.
1045 The following shall be declared as functions and may also be defined
1046 as macros. Function prototypes shall be provided.
1051 \fBint access(const char *, int);
1052 unsigned alarm(unsigned);
1053 int chdir(const char *);
1054 int chown(const char *, uid_t, gid_t);
1056 size_t confstr(int, char *, size_t);
1060 char *crypt(const char *, const char *);
1061 char *ctermid(char *);
1068 void encrypt(char[64], int);
1070 int execl(const char *, const char *, ...);
1071 int execle(const char *, const char *, ...);
1072 int execlp(const char *, const char *, ...);
1073 int execv(const char *, char *const []);
1074 int execve(const char *, char *const [], char *const []);
1075 int execvp(const char *, char *const []);
1077 int fchown(int, uid_t, gid_t);
1085 long fpathconf(int, int);
1089 int ftruncate(int, off_t);
1090 char *getcwd(char *, size_t);
1091 gid_t getegid(void);
1092 uid_t geteuid(void);
1094 int getgroups(int, gid_t []);
1096 long gethostid(void);
1098 int gethostname(char *, size_t);
1099 char *getlogin(void);
1100 int getlogin_r(char *, size_t);
1101 int getopt(int, char * const [], const char *);
1103 pid_t getpgid(pid_t);
1105 pid_t getpgrp(void);
1107 pid_t getppid(void);
1109 pid_t getsid(pid_t);
1113 char *getwd(char *); (\fP\fBLEGACY\fP \fB)
1117 int lchown(const char *, uid_t, gid_t);
1119 int link(const char *, const char *);
1121 int lockf(int, int, off_t);
1123 off_t lseek(int, off_t, int);
1127 long pathconf(const char *, int);
1131 ssize_t pread(int, void *, size_t, off_t);
1132 ssize_t pwrite(int, const void *, size_t, off_t);
1134 ssize_t read(int, void *, size_t);
1135 ssize_t readlink(const char *restrict, char *restrict, size_t);
1136 int rmdir(const char *);
1142 int setpgid(pid_t, pid_t);
1144 pid_t setpgrp(void);
1145 int setregid(gid_t, gid_t);
1146 int setreuid(uid_t, uid_t);
1150 unsigned sleep(unsigned);
1152 void swab(const void *restrict, void *restrict, ssize_t);
1153 int symlink(const char *, const char *);
1157 pid_t tcgetpgrp(int);
1158 int tcsetpgrp(int, pid_t);
1160 int truncate(const char *, off_t);
1163 int ttyname_r(int, char *, size_t);
1165 useconds_t ualarm(useconds_t, useconds_t);
1167 int unlink(const char *);
1169 int usleep(useconds_t);
1172 ssize_t write(int, const void *, size_t);
1177 Implementations may also include the \fIpthread_atfork\fP() prototype
1179 in \fI<pthread.h>\fP .
1181 The following external variables shall be declared:
1186 \fBextern char *optarg;
1187 extern int optind, opterr, optopt;
1192 \fIThe following sections are informative.\fP
1193 .SH APPLICATION USAGE
1195 IEEE\ Std\ 1003.1-2001 only describes the behavior of systems that
1196 claim conformance to it. However, application
1197 developers who want to write applications that adapt to other versions
1198 of IEEE\ Std\ 1003.1 (or to systems that do not
1199 conform to any POSIX standard) may find it useful to code them so
1200 as to conditionally compile different code depending on the value
1201 of _POSIX_VERSION, for example:
1206 \fB#if _POSIX_VERSION >= 200112L
1207 /* Use the newer function that copes with large files. */
1208 off_t pos=ftello(fp);
1210 /* Either this is an old version of POSIX, or _POSIX_VERSION is
1211 not even defined, so use the traditional function. */
1218 Earlier versions of IEEE\ Std\ 1003.1 and of the Single UNIX Specification
1219 can be identified by the following
1222 POSIX.1-1988 standard
1223 _POSIX_VERSION==198808L
1225 POSIX.1-1990 standard
1226 _POSIX_VERSION==199009L
1228 ISO\ POSIX-1:1996 standard
1229 _POSIX_VERSION==199506L
1231 Single UNIX Specification, Version 1
1232 _XOPEN_UNIX and _XOPEN_VERSION==4
1234 Single UNIX Specification, Version 2
1235 _XOPEN_UNIX and _XOPEN_VERSION==500
1238 IEEE\ Std\ 1003.1-2001 does not make any attempt to define application
1239 binary interaction with the underlying operating
1240 system. However, application developers may find it useful to query
1241 _SC_VERSION at runtime via \fIsysconf\fP() to determine whether the
1242 current version of the operating system supports the
1243 necessary functionality as in the following program fragment:
1248 \fBif (sysconf(_SC_VERSION) < 200112L) {
1249 fprintf(stderr, "POSIX.1-2001 system required, terminating \\n");
1256 New applications should not use _XOPEN_SHM or _XOPEN_ENH_I18N.
1259 As IEEE\ Std\ 1003.1-2001 evolved, certain options became sufficiently
1260 standardized that it was concluded that simply
1261 requiring one of the option choices was simpler than retaining the
1262 option. However, for backwards-compatibility, the option flags
1263 (with required constant values) are retained.
1264 .SS Version Test Macros
1266 The standard developers considered altering the definition of _POSIX_VERSION
1267 and removing _SC_VERSION from the specification of
1268 \fIsysconf\fP() since the utility to an application was deemed by
1269 some to be minimal, and
1270 since the implementation of the functionality is potentially problematic.
1271 However, they recognized that support for existing
1272 application binaries is a concern to manufacturers, application developers,
1273 and the users of implementations conforming to
1274 IEEE\ Std\ 1003.1-2001.
1276 While the example using _SC_VERSION in the APPLICATION USAGE section
1277 does not provide the greatest degree of imaginable utility
1278 to the application developer or user, it is arguably better than a
1279 \fBcore\fP file or some other equally obscure result. (It is
1280 also possible for implementations to encode and recognize application
1281 binaries compiled in various POSIX.1-conforming environments,
1282 and modify the semantics of the underlying system to conform to the
1283 expectations of the application.) For the reasons outlined in
1284 the preceding paragraphs and in the APPLICATION USAGE section, the
1285 standard developers elected to retain the _POSIX_VERSION and
1286 _SC_VERSION functionality.
1287 .SS Compile-Time Symbolic Constants for System-Wide Options
1289 IEEE\ Std\ 1003.1-2001 now includes support in certain areas for the
1290 newly adopted policy governing options and
1293 This policy provides flexibility for implementations in how they support
1294 options. It also specifies how conforming applications
1295 can adapt to different implementations that support different sets
1296 of options. It allows the following:
1298 If an implementation has no interest in supporting an option, it does
1299 not have to provide anything associated with that option
1300 beyond the announcement that it does not support it.
1303 An implementation can support a partial or incompatible version of
1304 an option (as a non-standard extension) as long as it does
1305 not claim to support the option.
1308 An application can determine whether the option is supported. A strictly
1309 conforming application must check this announcement
1310 mechanism before first using anything associated with the option.
1313 There is an important implication of this policy. IEEE\ Std\ 1003.1-2001
1314 cannot dictate the behavior of interfaces
1315 associated with an option when the implementation does not claim to
1316 support the option. In particular, it cannot require that a
1317 function associated with an unsupported option will fail if it does
1318 not perform as specified. However, this policy does not prevent
1319 a standard from requiring certain functions to always be present,
1320 but that they shall always fail on some implementations. The \fIsetpgid\fP()
1321 function in the POSIX.1-1990 standard, for example, is considered
1324 The POSIX standards include various options, and the C-language binding
1325 support for an option implies that the implementation
1326 must supply data types and function interfaces. An application must
1327 be able to discover whether the implementation supports each
1330 Any application must consider the following three cases for each option:
1332 Option never supported.
1334 The implementation advertises at compile time that the option will
1335 never be supported. In this case, it is not necessary for the
1336 implementation to supply any of the data types or function interfaces
1337 that are provided only as part of the option. The
1338 implementation might provide data types and functions that are similar
1339 to those defined by IEEE\ Std\ 1003.1-2001, but
1340 there is no guarantee for any particular behavior.
1343 Option always supported.
1345 The implementation advertises at compile time that the option will
1346 always be supported. In this case, all data types and
1347 function interfaces shall be available and shall operate as specified.
1350 Option might or might not be supported.
1352 Some implementations might not provide a mechanism to specify support
1353 of options at compile time. In addition, the
1354 implementation might be unable or unwilling to specify support or
1355 non-support at compile time. In either case, any application that
1356 might use the option at runtime must be able to compile and execute.
1357 The implementation must provide, at compile time, all data
1358 types and function interfaces that are necessary to allow this. In
1359 this situation, there must be a mechanism that allows the
1360 application to query, at runtime, whether the option is supported.
1361 If the application attempts to use the option when it is not
1362 supported, the result is unspecified unless explicitly specified otherwise
1363 in IEEE\ Std\ 1003.1-2001.
1365 .SH FUTURE DIRECTIONS
1370 \fI<inttypes.h>\fP , \fI<limits.h>\fP , \fI<sys/socket.h>\fP , \fI<sys/types.h>\fP
1371 , \fI<termios.h>\fP , \fI<wctype.h>\fP , the System Interfaces volume
1372 of IEEE\ Std\ 1003.1-2001, \fIaccess\fP(), \fIalarm\fP(), \fIchdir\fP(),
1373 \fIchown\fP(), \fIclose\fP(), \fIcrypt\fP(), \fIctermid\fP(), \fIdup\fP(),
1374 \fIencrypt\fP(), \fIenviron\fP, \fIexec\fP, \fIexit\fP(), \fIfchdir\fP(),
1375 \fIfchown\fP(), \fIfcntl\fP(), \fIfork\fP(), \fIfpathconf\fP(), \fIfsync\fP(),
1376 \fIftruncate\fP(), \fIgetcwd\fP(), \fIgetegid\fP(), \fIgeteuid\fP(),
1377 \fIgetgid\fP(), \fIgetgroups\fP(), \fIgethostid\fP(), \fIgethostname\fP(),
1378 \fIgetlogin\fP(), \fIgetpgid\fP(), \fIgetpgrp\fP(), \fIgetpid\fP(),
1379 \fIgetppid\fP(), \fIgetsid\fP(), \fIgetuid\fP(), \fIisatty\fP(), \fIlchown\fP(),
1380 \fIlink\fP(), \fIlockf\fP(), \fIlseek\fP(), \fInice\fP(), \fIpathconf\fP(),
1381 \fIpause\fP(), \fIpipe\fP(), \fIread\fP(), \fIreadlink\fP(), \fIrmdir\fP(),
1382 \fIsetgid\fP(), \fIsetpgid\fP(), \fIsetpgrp\fP(), \fIsetregid\fP(),
1383 \fIsetreuid\fP(), \fIsetsid\fP(), \fIsetuid\fP(), \fIsleep\fP(), \fIswab\fP(),
1384 \fIsymlink\fP(), \fIsync\fP(), \fIsysconf\fP(), \fItcgetpgrp\fP(),
1385 \fItcsetpgrp\fP(), \fItruncate\fP(), \fIttyname\fP(), \fIualarm\fP(),
1386 \fIunlink\fP(), \fIusleep\fP(), \fIvfork\fP(), \fIwrite\fP()
1388 Portions of this text are reprinted and reproduced in electronic form
1389 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
1390 -- Portable Operating System Interface (POSIX), The Open Group Base
1391 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
1392 Electrical and Electronics Engineers, Inc and The Open Group. In the
1393 event of any discrepancy between this version and the original IEEE and
1394 The Open Group Standard, the original IEEE and The Open Group Standard
1395 is the referee document. The original Standard can be obtained online at
1396 http://www.opengroup.org/unix/online.html .