📄 unistd.h.html
字号:
<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">void encrypt(char[64], int);<img src="../images/opt-end.gif" alt="[Option End]" border="0">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 []);void _exit(int);int fchown(int, uid_t, gid_t);<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">int fchdir(int);<img src="../images/opt-end.gif" alt="[Option End]" border="0"><sup>[<a href="javascript:open_code('SIO')">SIO</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">int fdatasync(int);<img src="../images/opt-end.gif" alt="[Option End]" border="0">pid_t fork(void);long fpathconf(int, int);<sup>[<a href="javascript:open_code('FSC')">FSC</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">int fsync(int);<img src="../images/opt-end.gif" alt="[Option End]" border="0">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 []);<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">long gethostid(void);<img src="../images/opt-end.gif" alt="[Option End]" border="0">int gethostname(char *, size_t);char *getlogin(void);int getlogin_r(char *, size_t);int getopt(int, char * const [], const char *);<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">pid_t getpgid(pid_t);<img src="../images/opt-end.gif" alt="[Option End]" border="0">pid_t getpgrp(void);pid_t getpid(void);pid_t getppid(void);<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">pid_t getsid(pid_t);<img src="../images/opt-end.gif" alt="[Option End]" border="0">uid_t getuid(void);<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">char *getwd(char *); (</tt><b>LEGACY</b> <tt>)<img src="../images/opt-end.gif" alt="[Option End]" border="0">int isatty(int);<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">int lchown(const char *, uid_t, gid_t);<img src="../images/opt-end.gif" alt="[Option End]" border="0">int link(const char *, const char *);<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">int lockf(int, int, off_t);<img src="../images/opt-end.gif" alt="[Option End]" border="0">off_t lseek(int, off_t, int);<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">int nice(int);<img src="../images/opt-end.gif" alt="[Option End]" border="0">long pathconf(const char *, int);int pause(void);int pipe(int [2]);<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">ssize_t pread(int, void *, size_t, off_t);ssize_t pwrite(int, const void *, size_t, off_t);<img src="../images/opt-end.gif" alt="[Option End]" border="0">ssize_t read(int, void *, size_t);ssize_t readlink(const char *restrict, char *restrict, size_t);int rmdir(const char *);int setegid(gid_t);int seteuid(uid_t);int setgid(gid_t);<br>int setpgid(pid_t, pid_t);<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">pid_t setpgrp(void);int setregid(gid_t, gid_t);int setreuid(uid_t, uid_t);<img src="../images/opt-end.gif" alt="[Option End]" border="0">pid_t setsid(void);int setuid(uid_t);unsigned sleep(unsigned);<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">void swab(const void *restrict, void *restrict, ssize_t);<img src="../images/opt-end.gif" alt="[Option End]" border="0">int symlink(const char *, const char *);<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">void sync(void);<img src="../images/opt-end.gif" alt="[Option End]" border="0">long sysconf(int);pid_t tcgetpgrp(int);int tcsetpgrp(int, pid_t);<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">int truncate(const char *, off_t);<img src="../images/opt-end.gif" alt="[Option End]" border="0">char *ttyname(int);int ttyname_r(int, char *, size_t);<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">useconds_t ualarm(useconds_t, useconds_t);<img src="../images/opt-end.gif" alt="[Option End]" border="0">int unlink(const char *);<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">int usleep(useconds_t);pid_t vfork(void);<img src="../images/opt-end.gif" alt="[Option End]" border="0">ssize_t write(int, const void *, size_t);</tt></pre><p>Implementations may also include the <a href="../functions/pthread_atfork.html"><i>pthread_atfork</i>()</a> prototype as definedin <a href="pthread.h.html"><i><pthread.h></i></a>.</p><p>The following external variables shall be declared:</p><pre><tt>extern char *optarg;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 Std 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 Std 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 >= 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 Std 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 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 Std 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) < 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 Std 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 Std 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 Std 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 Std 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 Std 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 me
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -