⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unistd.h.html

📁 IEEE 1003.1-2003, Single Unix Specification v3
💻 HTML
📖 第 1 页 / 共 5 页
字号:
extern int    optind, opterr, optopt;</tt></pre></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_13_80_04"></a>APPLICATION USAGE</h4><blockquote><p>IEEE&nbsp;Std&nbsp;1003.1-2001 only describes the behavior of systems that claim conformance to it. However, applicationdevelopers who want to write applications that adapt to other versions of IEEE&nbsp;Std&nbsp;1003.1 (or to systems that do notconform to any POSIX standard) may find it useful to code them so as to conditionally compile different code depending on the valueof _POSIX_VERSION, for example:</p><pre><tt>#if _POSIX_VERSION &gt;= 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</tt></pre><p>Earlier versions of IEEE&nbsp;Std&nbsp;1003.1 and of the Single UNIX Specification can be identified by the followingmacros:</p><dl compact><dt>POSIX.1-1988 standard</dt><dd>_POSIX_VERSION==198808L</dd><dt>POSIX.1-1990 standard</dt><dd>_POSIX_VERSION==199009L</dd><dt>ISO&nbsp;POSIX-1:1996 standard</dt><dd>_POSIX_VERSION==199506L</dd><dt>Single UNIX Specification, Version 1</dt><dd>_XOPEN_UNIX and _XOPEN_VERSION==4</dd><dt>Single UNIX Specification, Version 2</dt><dd>_XOPEN_UNIX and _XOPEN_VERSION==500</dd></dl><p>IEEE&nbsp;Std&nbsp;1003.1-2001 does not make any attempt to define application binary interaction with the underlying operatingsystem. However, application developers may find it useful to query _SC_VERSION at runtime via <a href="../functions/sysconf.html"><i>sysconf</i>()</a> to determine whether the current version of the operating system supports thenecessary functionality as in the following program fragment:</p><pre><tt>if (sysconf(_SC_VERSION) &lt; 200112L) {    fprintf(stderr, "POSIX.1-2001 system required, terminating \n");    exit(1);}</tt></pre><p>New applications should not use _XOPEN_SHM or _XOPEN_ENH_I18N.</p></blockquote><h4><a name="tag_13_80_05"></a>RATIONALE</h4><blockquote><p>As IEEE&nbsp;Std&nbsp;1003.1-2001 evolved, certain options became sufficiently standardized that it was concluded that simplyrequiring one of the option choices was simpler than retaining the option. However, for backwards-compatibility, the option flags(with required constant values) are retained.</p><h5><a name="tag_13_80_05_01"></a>Version Test Macros</h5><p>The standard developers considered altering the definition of _POSIX_VERSION and removing _SC_VERSION from the specification of<a href="../functions/sysconf.html"><i>sysconf</i>()</a> since the utility to an application was deemed by some to be minimal, andsince the implementation of the functionality is potentially problematic. However, they recognized that support for existingapplication binaries is a concern to manufacturers, application developers, and the users of implementations conforming toIEEE&nbsp;Std&nbsp;1003.1-2001.</p><p>While the example using _SC_VERSION in the APPLICATION USAGE section does not provide the greatest degree of imaginable utilityto the application developer or user, it is arguably better than a <b>core</b> file or some other equally obscure result. (It isalso possible for implementations to encode and recognize application binaries compiled in various POSIX.1-conforming environments,and modify the semantics of the underlying system to conform to the expectations of the application.) For the reasons outlined inthe preceding paragraphs and in the APPLICATION USAGE section, the standard developers elected to retain the _POSIX_VERSION and_SC_VERSION functionality.</p><h5><a name="tag_13_80_05_02"></a>Compile-Time Symbolic Constants for System-Wide Options</h5><p>IEEE&nbsp;Std&nbsp;1003.1-2001 now includes support in certain areas for the newly adopted policy governing options andstubs.</p><p>This policy provides flexibility for implementations in how they support options. It also specifies how conforming applicationscan adapt to different implementations that support different sets of options. It allows the following:</p><ol><li><p>If an implementation has no interest in supporting an option, it does not have to provide anything associated with that optionbeyond the announcement that it does not support it.</p></li><li><p>An implementation can support a partial or incompatible version of an option (as a non-standard extension) as long as it doesnot claim to support the option.</p></li><li><p>An application can determine whether the option is supported. A strictly conforming application must check this announcementmechanism before first using anything associated with the option.</p></li></ol><p>There is an important implication of this policy. IEEE&nbsp;Std&nbsp;1003.1-2001 cannot dictate the behavior of interfacesassociated with an option when the implementation does not claim to support the option. In particular, it cannot require that afunction associated with an unsupported option will fail if it does not perform as specified. However, this policy does not preventa standard from requiring certain functions to always be present, but that they shall always fail on some implementations. The <ahref="../functions/setpgid.html"><i>setpgid</i>()</a> function in the POSIX.1-1990 standard, for example, is consideredappropriate.</p><p>The POSIX standards include various options, and the C-language binding support for an option implies that the implementationmust supply data types and function interfaces. An application must be able to discover whether the implementation supports eachoption.</p><p>Any application must consider the following three cases for each option:</p><ol><li><p>Option never supported.</p><p>The implementation advertises at compile time that the option will never be supported. In this case, it is not necessary for theimplementation to supply any of the data types or function interfaces that are provided only as part of the option. Theimplementation might provide data types and functions that are similar to those defined by IEEE&nbsp;Std&nbsp;1003.1-2001, butthere is no guarantee for any particular behavior.</p></li><li><p>Option always supported.</p><p>The implementation advertises at compile time that the option will always be supported. In this case, all data types andfunction interfaces shall be available and shall operate as specified.</p></li><li><p>Option might or might not be supported.</p><p>Some implementations might not provide a mechanism to specify support of options at compile time. In addition, theimplementation might be unable or unwilling to specify support or non-support at compile time. In either case, any application thatmight use the option at runtime must be able to compile and execute. The implementation must provide, at compile time, all datatypes and function interfaces that are necessary to allow this. In this situation, there must be a mechanism that allows theapplication to query, at runtime, whether the option is supported. If the application attempts to use the option when it is notsupported, the result is unspecified unless explicitly specified otherwise in IEEE&nbsp;Std&nbsp;1003.1-2001.</p></li></ol></blockquote><h4><a name="tag_13_80_06"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_13_80_07"></a>SEE ALSO</h4><blockquote><p><a href="inttypes.h.html"><i>&lt;inttypes.h&gt;</i></a> , <a href="limits.h.html"><i>&lt;limits.h&gt;</i></a> , <a href="sys/socket.h.html"><i>&lt;sys/socket.h&gt;</i></a> , <a href="sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> , <a href="termios.h.html"><i>&lt;termios.h&gt;</i></a> , <a href="wctype.h.html"><i>&lt;wctype.h&gt;</i></a> , the System Interfaces volumeof IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../functions/access.html"><i>access</i>()</a>, <a href="../functions/alarm.html"><i>alarm</i>()</a>, <a href="../functions/chdir.html"><i>chdir</i>()</a>, <a href="../functions/chown.html"><i>chown</i>()</a>, <a href="../functions/close.html"><i>close</i>()</a>, <a href="../functions/crypt.html"><i>crypt</i>()</a>, <a href="../functions/ctermid.html"><i>ctermid</i>()</a>, <a href="../functions/dup.html"><i>dup</i>()</a>, <a href="../functions/encrypt.html"><i>encrypt</i>()</a>, <i>environ</i>, <i>exec</i>, <ahref="../functions/exit.html"><i>exit</i>()</a>, <a href="../functions/fchdir.html"><i>fchdir</i>()</a>, <a href="../functions/fchown.html"><i>fchown</i>()</a>, <a href="../functions/fcntl.html"><i>fcntl</i>()</a>, <a href="../functions/fork.html"><i>fork</i>()</a>, <a href="../functions/fpathconf.html"><i>fpathconf</i>()</a>, <a href="../functions/fsync.html"><i>fsync</i>()</a>, <a href="../functions/ftruncate.html"><i>ftruncate</i>()</a>, <a href="../functions/getcwd.html"><i>getcwd</i>()</a>, <a href="../functions/getegid.html"><i>getegid</i>()</a>, <a href="../functions/geteuid.html"><i>geteuid</i>()</a>, <a href="../functions/getgid.html"><i>getgid</i>()</a>, <a href="../functions/getgroups.html"><i>getgroups</i>()</a>, <a href="../functions/gethostid.html"><i>gethostid</i>()</a>, <a href="../functions/gethostname.html"><i>gethostname</i>()</a>, <a href="../functions/getlogin.html"><i>getlogin</i>()</a>, <a href="../functions/getpgid.html"><i>getpgid</i>()</a>, <a href="../functions/getpgrp.html"><i>getpgrp</i>()</a>, <a href="../functions/getpid.html"><i>getpid</i>()</a>, <a href="../functions/getppid.html"><i>getppid</i>()</a>, <a href="../functions/getsid.html"><i>getsid</i>()</a>, <a href="../functions/getuid.html"><i>getuid</i>()</a>, <a href="../functions/isatty.html"><i>isatty</i>()</a>, <a href="../functions/lchown.html"><i>lchown</i>()</a>, <a href="../functions/link.html"><i>link</i>()</a>, <a href="../functions/lockf.html"><i>lockf</i>()</a>, <a href="../functions/lseek.html"><i>lseek</i>()</a>, <a href="../functions/nice.html"><i>nice</i>()</a>, <a href="../functions/pathconf.html"><i>pathconf</i>()</a>, <a href="../functions/pause.html"><i>pause</i>()</a>, <a href="../functions/pipe.html"><i>pipe</i>()</a>, <a href="../functions/read.html"><i>read</i>()</a>, <a href="../functions/readlink.html"><i>readlink</i>()</a>, <a href="../functions/rmdir.html"><i>rmdir</i>()</a>, <a href="../functions/setgid.html"><i>setgid</i>()</a>, <a href="../functions/setpgid.html"><i>setpgid</i>()</a>, <a href="../functions/setpgrp.html"><i>setpgrp</i>()</a>, <a href="../functions/setregid.html"><i>setregid</i>()</a>, <a href="../functions/setreuid.html"><i>setreuid</i>()</a>, <a href="../functions/setsid.html"><i>setsid</i>()</a>, <a href="../functions/setuid.html"><i>setuid</i>()</a>, <a href="../functions/sleep.html"><i>sleep</i>()</a>, <a href="../functions/swab.html"><i>swab</i>()</a>, <a href="../functions/symlink.html"><i>symlink</i>()</a>, <a href="../functions/sync.html"><i>sync</i>()</a>, <a href="../functions/sysconf.html"><i>sysconf</i>()</a>, <a href="../functions/tcgetpgrp.html"><i>tcgetpgrp</i>()</a>, <a href="../functions/tcsetpgrp.html"><i>tcsetpgrp</i>()</a>, <a href="../functions/truncate.html"><i>truncate</i>()</a>, <a href="../functions/ttyname.html"><i>ttyname</i>()</a>, <a href="../functions/ualarm.html"><i>ualarm</i>()</a>, <a href="../functions/unlink.html"><i>unlink</i>()</a>, <a href="../functions/usleep.html"><i>usleep</i>()</a>, <a href="../functions/vfork.html"><i>vfork</i>()</a>, <a href="../functions/write.html"><i>write</i>()</a></p></blockquote><h4><a name="tag_13_80_08"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 1. Derived from Issue 1 of the SVID.</p></blockquote><h4><a name="tag_13_80_09"></a>Issue 5</h4><blockquote><p>The DESCRIPTION is updated for alignment with the POSIX Realtime Extension and the POSIX Threads Extension.</p><p>The symbolic constants _XOPEN_REALTIME and _XOPEN_REALTIME_THREADS are added. _POSIX2_C_BIND, _XOPEN_ENH_I18N, and _XOPEN_SHMmust now be set to a value other than -1 by a conforming implementation.</p><p>Large File System extensions are added.</p><p>The type of the argument to <i>sbrk</i>() is changed from <b>int</b> to <b>intptr_t</b>.</p><p>_XBS_ constants are added to the list of constants for Options and Option Groups, to the list of constants for the <a href="../functions/confstr.html"><i>confstr</i>()</a> function, and to the list of constants to the <a href="../functions/sysconf.html"><i>sysconf</i>()</a> function. These are all marked EX.</p></blockquote><h4><a name="tag_13_80_10"></a>Issue 6</h4><blockquote><p>_POSIX2_C_VERSION is removed.</p><p>The Open Group Corrigendum U026/4 is applied, adding the prototype for <a href="../functions/fdatasync.html"><i>fdatasync</i>()</a>.</p><p>The Open Group Corrigendum U026/1 is applied, adding the symbols _SC_XOPEN_LEGACY, _SC_XOPEN_REALTIME, and_SC_XOPEN_REALTIME_THREADS.</p><p>The symbols _XOPEN_STREAMS and _SC_XOPEN_STREAMS are added to support the XSI STREAMS Option Group.</p><p>Text in the DESCRIPTION relating to conformance requirements is moved elsewhere in IEEE&nbsp;Std&nbsp;1003.1-2001.</p><p>The legacy symbol _SC_PASS_MAX is removed.</p><p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p><ul><li><p>The _CS_POSIX_* and _CS_XBS5_* constants are added for the <a href="../functions/confstr.html"><i>confstr</i>()</a>function.</p></li><li><p>The _SC_XBS5_* constants are added for the <a href="../functions/sysconf.html"><i>sysconf</i>()</a> function.</p></li><li><p>The symbolic constants F_ULOCK, F_LOCK, F_TLOCK, and F_TEST are added.</p></li><li><p>The <b>uid_t</b>, <b>gid_t</b>, <b>off_t</b>, <b>pid_t</b>, and <b>useconds_t</b> types are mandated.</p></li></ul><p>The <a href="../functions/gethostname.html"><i>gethostname</i>()</a> prototype is added for sockets.</p><p>A new section is added for System-Wide Options.</p><p>Function prototypes for <a href="../functions/setegid.html"><i>setegid</i>()</a> and <a href="../functions/seteuid.html"><i>seteuid</i>()</a> are added.</p><p>Option symbolic constants are added for _POSIX_ADVISORY_INFO, _POSIX_CPUTIME, _POSIX_SPAWN, _POSIX_SPORADIC_SERVER,_POSIX_THREAD_CPUTIME, _POSIX_THREAD_SPORADIC_SERVER, and _POSIX_TIMEOUTS, and <a href="../functions/pathconf.html"><i>pathconf</i>()</a> variables are added for _PC_ALLOC_SIZE_MIN, _PC_REC_INCR_XFER_SIZE,_PC_REC_MAX_XFER_SIZE, _PC_REC_MIN_XFER_SIZE, and _PC_REC_XFER_ALIGN for alignment with IEEE&nbsp;Std&nbsp;1003.1d-1999.</p><p>The following are added for alignment with IEEE&nb

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -