1unistd.h(3HEAD) Headers unistd.h(3HEAD)
2
3
4
6 unistd.h, unistd - standard symbolic constants and types
7
9 #include <unistd.h>
10
11
13 The <unistd.h> header defines the symbolic constants and structures
14 which are not already defined or declared in some other header. The
15 contents of this header are shown below.
16
17 Version Test Macros
18 The following symbolic constants are defined (with fixed values):
19
20 _POSIX_VERSION Integer value indicating version of the POSIX
21 standard (C language binding). See standards(5).
22
23
24 _POSIX2_VERSION Integer value indicating version of the POSIX.2
25 standard (Commands).
26
27
28 _POSIX2_C_VERSION Integer value indicating version of the POSIX.2
29 standard (C language binding).
30
31
32 _XOPEN_VERSION Integer value indicating version of the XPG to
33 which system conforms.
34
35
36 _XOPEN_XCU_VERSION Integer value indicating the version of the XCU
37 specification to which the implementation con‐
38 forms. If this constant is not defined, use the
39 sysconf(3C) function to determine which features
40 are supported. This constant is not defined for
41 the SUSv3 environment.
42
43
44 Mandatory Symbolic Constants
45 The following symbolic constants, if defined in <unistd.h>, have a
46 value of -1, 0, or greater, unless otherwise specified below. If these
47 are undefined, the fpathconf(2), pathconf(2), or sysconf(3C) functions
48 can be used to determine whether the option is provided for a particu‐
49 lar invocation of the application.
50
51
52 If a symbolic constant is defined with the value -1, the option is not
53 supported. Headers, data types, and function interfaces required only
54 for the option need not be supplied. An application that attempts to
55 use anything associated only with the option is considered to be
56 requiring an extension.
57
58
59 If a symbolic constant is defined with a value greater than zero, the
60 option is always supported when the application is executed. All head‐
61 ers, data types, and functions are present and operate as specified.
62
63
64 If a symbolic constant is defined with the value zero, all headers,
65 data types, and functions are present. The application can check at
66 runtime to see whether the option is supported by calling fpathconf(),
67 pathconf(), or sysconf() with the indicated name parameter.
68
69
70 Unless explicitly specified otherwise, the behavior of functions asso‐
71 ciated with an unsupported option is unspecified, and an application
72 that uses such functions without first checking fpathconf(), path‐
73 conf(), or sysconf() is considered to be requiring an extension.
74
75 _POSIX_ADVISORY_INFO
76
77 Implementation supports the Advisory Information option.
78
79
80 _POSIX_ASYNCHRONOUS_IO
81
82 Implementation supports the Asynchronous Input and Output option.
83
84
85 _POSIX_BARRIERS
86
87 Implementation supports the Barriers option.
88
89
90 _POSIX_CLOCK_SELECTION
91
92 Implementation supports the Clock Selection option.
93
94
95 _POSIX_CPUTIME
96
97 Implementation supports the Process CPU-Time Clocks option.
98
99
100 _POSIX_FSYNC
101
102 Implementation supports the File Synchronisation option.
103
104
105 _POSIX_IPV6
106
107 Implementation supports the IPv6 option.
108
109
110 _POSIX_JOB_CONTROL
111
112 Implementation supports job control.
113
114
115 _POSIX_MAPPED_FILES
116
117 Implementation supports the Memory Mapped Files option.
118
119
120 _POSIX_MEMLOCK
121
122 Implementation supports the Process Memory Locking option.
123
124
125 _POSIX_MEMLOCK_RANGE
126
127 Implementation supports the Range Memory Locking option.
128
129
130 _POSIX_MEMORY_PROTECTION
131
132 Implementation supports the Memory Protection option.
133
134
135 _POSIX_MESSAGE_PASSING
136
137 Implementation supports the Message Passing option.
138
139
140 _POSIX_MONOTONIC_CLOCK
141
142 Implementation supports the Monotonic Clock option.
143
144
145 _POSIX_PRIORITY_SCHEDULING
146
147 Implementation supports the Process Scheduling option.
148
149
150 _POSIX_RAW_SOCKETS
151
152 Implementation supports the Raw Sockets option.
153
154
155 _POSIX_READER_WRITER_LOCKS
156
157 Implementation supports the Read-Write Locks option.
158
159
160 _POSIX_REALTIME_SIGNALS
161
162 Implementation supports the Realtime Signals Extension option.
163
164
165 _POSIX_REGEXP
166
167 Implementation supports the Regular Expression Handling option.
168
169
170 _POSIX_SAVED_IDS
171
172 The exec functions (see exec(2)) save the effective user and group.
173
174
175 _POSIX_SEMAPHORES
176
177 Implementation supports the Semaphores option.
178
179
180 _POSIX_SHARED_MEMORY_OBJECTS
181
182 Implementation supports the Shared Memory Objects option.
183
184
185 _POSIX_SHELL
186
187 Implementation supports the POSIX shell.
188
189
190 _POSIX_SPAWN
191
192 Implementation supports the Spawn option.
193
194
195 _POSIX_SPIN_LOCKS
196
197 Implementation supports the Spin Locks option.
198
199
200 _POSIX_SPORADIC_SERVER
201
202 Implementation supports the Process Sporadic Server option.
203
204
205 _POSIX_SYNCHRONIZED_IO
206
207 Implementation supports the Synchronized Input and Output option.
208
209
210 _POSIX_THREAD_ATTR_STACKADDR
211
212 Implementation supports the thread stack address attribute option.
213
214
215 _POSIX_THREAD_ATTR_STACKSIZE
216
217 Implementation supports the thread stack size attribute option.
218
219
220 _POSIX_THREAD_CPUTIME
221
222 Implementation supports the Thread CPU-Time Clocks option.
223
224
225 _POSIX_THREAD_PROCESS_SHARED
226
227 Implementation supports the process-shared synchronization option.
228
229
230 _POSIX_THREAD_SAFE_FUNCTIONS
231
232 Implementation supports the thread-safe functions option.
233
234
235 _POSIX_THREAD_SPORADIC_SERVER
236
237 Implementation supports the Thread Sporadic Server option.
238
239
240 _POSIX_THREADS
241
242 Implementation supports the threads option.
243
244
245 _POSIX_TIMERS
246
247 Implementation supports the Timers option.
248
249
250 _POSIX_TIMEOUTS
251
252 Implementation supports the Timeouts option.
253
254
255 _POSIX_TRACE
256
257 Implementation supports the Trace option.
258
259
260 _POSIX_TRACE_EVENT_FILTER
261
262 Implementation supports the Trace Event Filter option.
263
264
265 _POSIX_TRACE_INHERIT
266
267 Implementation supports the Trace Inherit option.
268
269
270 _POSIX_TRACE_LOG
271
272 Implementation supports the Trace Log option.
273
274
275 _POSIX_TYPED_MEMORY_OBJECTS
276
277 Implementation supports the Typed Memory Objects option.
278
279
280 _POSIX_V6_ILP32_OFF32
281
282 Implementation provides a C-language compilation environment with
283 32-bit int, long, and pointer types and an off_t type using at
284 least 64 bits.
285
286
287 _POSIX_V6_ILP32_OFFBIG
288
289 Implementation provides a C-language compilation environment with
290 32-bit int, long, and pointer types and an off_t type using at
291 least 64 bits.
292
293
294 _POSIX_V6_LP64_OFF64
295
296 Implementation provides a C-language compilation environment with
297 32-bit int and 64-bit long, pointer, and off_t types.
298
299
300 _POSIX_V6_LPBIG_OFFBIG
301
302 Implementation provides a C-language compilation environment with
303 an int type using at least 32 bits and long, pointer, and off_t
304 types using at least 64 bits.
305
306
307 _POSIX_XOPEN_STREAMS
308
309 Implementation supports the XSI STREAMS Option Group.
310
311
312 _POSIX2_C_BIND
313
314 Implementation supports the C Language Binding option.
315
316
317 _POSIX2_C_DEV
318
319 Implementation supports the C Language Development Utilities
320 option.
321
322
323 _POSIX2_CHAR_TERM
324
325 Implementation supports at least one terminal type.
326
327
328 _POSIX2_LOCALEDEF
329
330 Implementation supports the creation of locales by the localedef(1)
331 utility.
332
333
334 _POSIX2_PBS
335
336 Implementation supports the Batch Environment Services and Utili‐
337 ties option.
338
339
340 _POSIX2_PBS_ACCOUNTING
341
342 Implementation supports the Batch Accounting option.
343
344
345 _POSIX2_PBS_CHECKPOINT
346
347 Implementation supports the Batch Checkpoint/Restart option.
348
349
350 _POSIX2_PBS_LOCATE
351
352 Implementation supports the Locate Batch Job Request option.
353
354
355 _POSIX2_PBS_MESSAGE
356
357 Implementation supports the Batch Job Message Request option.
358
359
360 _POSIX2_PBS_TRACK
361
362 Implementation supports the Track Batch Job Request option.
363
364
365 _POSIX2_SW_DEV
366
367 Implementation supports the Software Development Utilities option.
368
369
370 _POSIX2_UPE
371
372 Implementation supports the User Portability Utilities option.
373
374
375 _XBS5_ILP32_OFF32
376
377 Implementation provides a C-language compilation environment with
378 32-bit int, long, pointer and off_t types.
379
380
381 _XBS5_ILP32_OFFBIG
382
383 Implementation provides a C-language compilation environment with
384 32-bit int, long and pointer types and an off_t type using at least
385 64 bits.
386
387
388 _XBS5_LP64_OFF64
389
390 Implementation provides a C-language compilation environment with
391 32-bit int and 64-bit long, pointer and off_t types.
392
393
394 _XBS5_LPBIG_OFFBIG
395
396 Implementation provides a C-language compilation environment with
397 an int type using at least 32 bits and long, pointer and off_t
398 types using at least 64 bits.
399
400
401 _XOPEN_ENH_I18N
402
403 Implementation supports the Issue 4, Version 2 Enhanced Interna‐
404 tionalization Feature Group.
405
406
407 _XOPEN_LEGACY
408
409 Implementation supports the Legacy Feature Group.
410
411
412 _XOPEN_REALTIME
413
414 Implementation supports the X/Open Realtime Feature Group.
415
416
417 _XOPEN_SHM
418
419 Implementation supports the Issue 4, Version 2 Shared Memory Fea‐
420 ture Group.
421
422
423 _XOPEN_UNIX
424
425 X/Open CAE Specification, January 1997, System Interfaces and Head‐
426 ers, Issue 5 (ISBN: 1-85912-181-0, C606).
427
428
429 _XOPEN_XPG3
430
431 X/Open Specification, February 1992, System Interfaces and Headers,
432 Issue 3 (ISBN: 1-872630-37-5, C212); this specification was for‐
433 merly X/Open Portability Guide, Issue 3, Volume 2, January 1989,
434 XSI System Interface and Headers (ISBN: 0-13-685843-0,
435 XO/XPG/89/003).
436
437
438 _XOPEN_XPG4
439
440 X/Open CAE Specification, July 1992, System Interfaces and Headers,
441 Issue 4 (ISBN: 1-872630-47-2, C202).
442
443
444 Execution-time Symbolic Constants
445 If any of the following constants are not defined in the header
446 <unistd.h>, the value varies depending on the file to which it is
447 applied.
448
449
450 If any of the following constants are defined to have value −1 in the
451 header <unistd.h>, the implementation will not provide the option on
452 any file; if any are defined to have a value other than −1 in the
453 header <unistd.h>, the implementation will provide the option on all
454 applicable files.
455
456
457 All of the following constants, whether defined in <unistd.h> or not,
458 can be queried with respect to a specific file using the pathconf() or
459 fpathconf() functions.
460
461 _POSIX_ASYNC_IO Asynchronous input or output operations can be per‐
462 formed for the associated file.
463
464
465 _POSIX_PRIO_IO Prioritized input or output operations can be per‐
466 formed for the associated file.
467
468
469 _POSIX_SYNC_IO Synchronized input or output operations can be per‐
470 formed for the associated file.
471
472
473 Constants for Functions
474 The following constant is defined:
475
476 NULL Null pointer.
477
478
479
480 The following symbolic constants are defined for the access(2) func‐
481 tion:
482
483 R_OK Test for read permission.
484
485
486 W_OK Test for write permission.
487
488
489 X_OK Test for execute (search) permission.
490
491
492 F_OK Test for existence of file.
493
494
495
496 The constants F_OK, R_OK, W_OK, and X_OK, and the expressions
497 R_OK|W_OK, R_OK|X_OK, and R_OK|W_OK|X_OK all have distinct values.
498
499
500 The following symbolic constants are defined for the lockf(3C) func‐
501 tion:
502
503 F_ULOCK Unlock a previously locked region.
504
505
506 F_LOCK Lock a region for exclusive use.
507
508
509 F_TLOCK Test and lock a region for exclusive use.
510
511
512 F_TEST Test a region for other processes locks.
513
514
515
516 The following symbolic constants are defined for the lseek(2) and
517 fcntl(2) functions (they have distinct values):
518
519 SEEK_SET Set file offset to offset.
520
521
522 SEEK_CUR Set file offset to current plus offset.
523
524
525 SEEK_END Set file offset to EOF plus offset.
526
527
528
529 The following symbolic constants are defined for the confstr(3C) func‐
530 tion for both SPARC and x86:
531
532
533
534
535 _CS_LFS64_CFLAGS _CS_LFS64_LDFLAGS
536 _CS_LFS64_LIBS _CS_LFS64_LINTFLAGS
537 _CS_LFS_CFLAGS _CS_LFS_LDFLAGS
538 _CS_LFS_LIBS _CS_LFS_LINTFLAGS
539 _CS_PATH _CS_POSIX_V6_ILP32_OFF32_CFLAGS
540 _CS_POSIX_V6_ILP32_OFF32_LDFLAGS _CS_POSIX_V6_ILP32_OFF32_LIBS
541 _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS
542 _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LIBS
543 _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS _CS_POSIX_V6_WIDTH_RESTRICTED_ENV
544 _CS_XBS5_ILP32_OFF32_CFLAGS _CS_XBS5_ILP32_OFF32_LDFLAGS
545 _CS_XBS5_ILP32_OFF32_LIBS _CS_XBS5_ILP32_OFF32_LINTFLAGS
546 _CS_XBS5_ILP32_OFFBIG_CFLAGS _CS_XBS5_ILP32_OFFBIG_LDFLAGS
547 _CS_XBS5_ILP32_OFFBIG_LIBS _CS_XBS5_ILP32_OFFBIG_LINTFLAGS
548
549
550
551 The followwing symbolic constants are defined for the confstr() func‐
552 tion for SPARC only:
553
554
555
556
557 _CS_POSIX_V6_LP64_OFF64_CFLAGS _CS_POSIX_V6_LP64_OFF64_LDFLAGS
558 _CS_POSIX_V6_LP64_OFF64_LIBS _CS_POSIX_V6_LP64_OFF64_LINTFLAGS
559 _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
560 _CS_POSIX_V6_LPBIG_OFFBIG_LIBS _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS
561 _CS_XBS5_LP64_OFF64_CFLAGS _CS_XBS5_LP64_OFF64_LDFLAGS
562 _CS_XBS5_LP64_OFF64_LIBS _CS_XBS5_LP64_OFF64_LINTFLAGS
563 _CS_XBS5_LPBIG_OFFBIG_CFLAGS _CS_XBS5_LPBIG_OFFBIG_LDFLAGS
564 _CS_XBS5_LPBIG_OFFBIG_LIBS _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS
565
566
567
568 The following symbolic constants are defined for the sysconf(3C) func‐
569 tion:
570
571
572
573
574 _SC_2_C_BIND _SC_2_C_DEV
575 _SC_2_C_VERSION _SC_2_FORT_DEV
576 _SC_2_FORT_RUN _SC_2_LOCALEDEF
577 _SC_2_PBS _SC_2_PBS_ACCOUNTING
578 _SC_2_PBS_CHECKPOINT _SC_2_PBS_LOCATE
579 _SC_2_PBS_MESSAGE _SC_2_PBS_TRACK
580 _SC_2_SW_DEV _SC_2_UPE
581 _SC_2_VERSION _SC_ADVISORY_INFO
582 _SC_AIO_LISTIO_MAX _SC_AIO_MAX
583 _SC_AIO_PRIO_DELTA_MAX _SC_ARG_MAX
584 _SC_ASYNCHRONOUS_IO _SC_ATEXIT_MAX
585 _SC_AVPHYS_PAGES _SC_BARRIERS
586 _SC_BC_BASE_MAX _SC_BC_DIM_MAX
587 _SC_BC_SCALE_MAX _SC_BC_STRING_MAX
588 _SC_CHILD_MAX _SC_CLK_TCK
589 _SC_CLOCK_SELECTION _SC_COLL_WEIGHTS_MAX
590 _SC_CPUTIME _SC_DELAYTIMER_MAX
591 _SC_EXPR_NEST_MAX _SC_FSYNC
592 _SC_GETGR_R_SIZE_MAX _SC_GETPW_R_SIZE_MAX
593 _SC_HOST_NAME_MAX _SC_IOV_MAX
594 _SC_IPV6 _SC_JOB_CONTROL
595 _SC_LINE_MAX _SC_LOGIN_NAME_MAX
596 _SC_LOGNAME_MAX _SC_MAPPED_FILES
597
598 _SC_MEMLOCK _SC_MEMLOCK_RANGE
599 _SC_MEMORY_PROTECTION _SC_MESSAGE_PASSING
600 _SC_MONOTONIC_CLOCK _SC_MQ_OPEN_MAX
601 _SC_MQ_PRIO_MAX _SC_NGROUPS_MAX
602 _SC_NPROCESSORS_CONF _SC_NPROCESSORS_ONLN
603 _SC_OPEN_MAX _SC_PAGESIZE
604 _SC_PAGE_SIZE _SC_PASS_MAX
605 _SC_PHYS_PAGES _SC_PRIORITIZED_IO
606 _SC_PRIORITY_SCHEDULING _SC_RAW_SOCKETS
607 _SC_READER_WRITER_LOCKS _SC_REALTIME_SIGNALS
608 _SC_REGEXP _SC_RE_DUP_MAX
609 _SC_RTSIG_MAX _SC_SAVED_IDS
610 _SC_SEMAPHORES _SC_SEM_NSEMS_MAX
611 _SC_SEM_VALUE_MAX _SC_SHARED_MEMORY_OBJECTS
612 _SC_SHELL _SC_SIGQUEUE_MAX
613 _SC_SPAWN _SC_SPIN_LOCKS
614 _SC_SPORADIC_SERVER _SC_SS_REPL_MAX
615 _SC_STREAM_MAX _SC_SYMLOOP_MAX
616 _SC_SYNCHRONIZED_IO _SC_THREAD_ATTR_STACKADDR
617 _SC_THREAD_ATTR_STACKSIZE _SC_THREAD_CPUTIME
618 _SC_THREAD_DESTRUCTOR_ITERATIONS _SC_THREAD_KEYS_MAX
619 _SC_THREAD_PRIO_INHERIT _SC_THREAD_PRIO_PROTECT
620 _SC_THREAD_PRIORITY_SCHEDULING _SC_THREAD_PROCESS_SHARED
621 _SC_THREAD_SPORADIC_SERVER _SC_THREADS
622 _SC_THREAD_SAFE_FUNCTIONS _SC_THREAD_STACK_MIN
623 _SC_THREAD_THREADS_MAX _SC_TIMEOUTS
624 _SC_TIMER_MAX _SC_TIMERS
625 _SC_TRACE _SC_TRACE_EVENT_FILTER
626 _SC_TRACE_EVENT_NAME_MAX _SC_TRACE_INHERIT
627 _SC_TRACE_LOG _SC_TRACE_NAME_MAX
628 _SC_TRACE_SYS_MAX _SC_TRACE_USER_EVENT_MAX
629 _SC_TTY_NAME_MAX _SC_TYPED_MEMORY_OBJECTS
630 _SC_TZNAME_MAX _SC_V6_ILP32_OFF32
631 _SC_V6_ILP32_OFFBIG _SC_V6_LP64_OFF64
632 _SC_V6_LPBIG_OFFBIG _SC_VERSION
633 _SC_XBS5_ILP32_OFF32 _SC_XBS5_ILP32_OFFBIG
634 _SC_XBS5_LP64_OFF64 _SC_XBS5_LPBIG_OFFBIG
635 _SC_XOPEN_CRYPT _SC_XOPEN_ENH_I18N
636 _SC_XOPEN_SHM _SC_XOPEN_STREAMS
637 _SC_XOPEN_UNIX _SC_XOPEN_VERSION
638 _SC_XOPEN_XCU_VERSION
639
640
641
642 The constants _SC_PAGESIZE and _SC_PAGE_SIZE can be defined to have the
643 same value.
644
645
646 The following symbolic constants are defined for the fpathconf(2) func‐
647 tion:
648
649
650
651
652 _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN
653 _PC_ASYNC_IO _PC_CHOWN_RESTRICTED
654 _PC_FILESIZEBITS _PC_LINK_MAX
655 _PC_MAX_CANON _PC_MAX_INPUT
656 _PC_NAME_MAX _PC_NO_TRUNC
657 _PC_PATH_MAX _PC_PIPE_BUF
658 _PC_PRIO_IO _PC_REC_INCR_XFER_SIZE
659 _PC_REC_MAX_XFER_SIZE _PC_REC_MIN_XFER_SIZE
660 _PC_REC_XFER_ALIGN _PC_SYMLINK_MAX
661 _PC_SYNC_IO _PC_TIMESTAMP_RESOLUTION
662 _PC_VDISABLE _PC_XATTR_ENABLED
663 _PC_XATTR_EXISTS
664
665
666
667 The following symbolic constants are defined for file streams:
668
669 STDIN_FILENO File number (0) of stdin.
670
671
672 STDOUT_FILENO File number (1) of stout.
673
674
675 STDERR_FILENO File number (2) of stderr.
676
677
678
679 The following pathnames are defined:
680
681 GF_PATH Pathname of the group file.
682
683
684 PF_PATH Pathname of the passwd file.
685
686
688 See attributes(5) for descriptions of the following attributes:
689
690
691
692
693 ┌─────────────────────────────┬─────────────────────────────┐
694 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
695 ├─────────────────────────────┼─────────────────────────────┤
696 │Interface Stability │Committed │
697 ├─────────────────────────────┼─────────────────────────────┤
698 │Standard │See standards(5). │
699 └─────────────────────────────┴─────────────────────────────┘
700
702 access(2), exec(2), fcntl(2), fpathconf(2), lseek(2), confstr(3C),
703 lockf(3C), sysconf(3C), termios(3C), group(4), passwd(4),
704 attributes(5), standards(5), termio(7I)
705
706
707
708SunOS 5.11 1 Sep 2009 unistd.h(3HEAD)