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

📄 _exit.html

📁 posix标准英文,html格式
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2004 IEEE and The Open Group, All Rights Reserved --><title>exit</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="exit"></a> <a name="tag_03_131"></a><!-- exit --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2004 Edition<br>Copyright &copy; 2001-2004 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_131_01"></a>NAME</h4><blockquote>exit, _Exit, _exit - terminate a process</blockquote><h4><a name="tag_03_131_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>#include &lt;<a href="../basedefs/stdlib.h.html">stdlib.h</a>&gt;<br><br> void exit(int</tt> <i>status</i><tt>);<br> void _Exit(int</tt> <i>status</i><tt>);<br><br><br> #include &lt;<a href="../basedefs/unistd.h.html">unistd.h</a>&gt;<br> void _exit(int</tt> <i>status</i><tt>);<br></tt></code></p></blockquote><h4><a name="tag_03_131_03"></a>DESCRIPTION</h4><blockquote><p>For <i>exit</i>() and <i>_Exit</i>(): <sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> The functionality described on this reference page is aligned with theISO&nbsp;C standard. Any conflict between the requirements described here and the ISO&nbsp;C standard is unintentional. This volumeof IEEE&nbsp;Std&nbsp;1003.1-2001 defers to the ISO&nbsp;C standard. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>The value of <i>status</i> may be 0, EXIT_SUCCESS, EXIT_FAILURE, <sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <imgsrc="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;or any other value, though only the least significant 8 bits(that is, <i>status</i> &amp; 0377) shall be available to a waiting parent process. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>The <i>exit</i>() function shall first call all functions registered by <a href="../functions/atexit.html"><i>atexit</i>()</a>,in the reverse order of their registration, except that a function is called after any previously registered functions that hadalready been called at the time it was registered. Each function is called as many times as it was registered. If, during the callto any such function, a call to the <a href="../functions/longjmp.html"><i>longjmp</i>()</a> function is made that would terminatethe call to the registered function, the behavior is undefined.</p><p>If a function registered by a call to <a href="../functions/atexit.html"><i>atexit</i>()</a> fails to return, the remainingregistered functions shall not be called and the rest of the <i>exit</i>() processing shall not be completed. If <i>exit</i>() iscalled more than once, the behavior is undefined.</p><p>The <i>exit</i>() function shall then flush all open streams with unwritten buffered data, close all open streams, and removeall files created by <a href="../functions/tmpfile.html"><i>tmpfile</i>()</a>. Finally, control shall be terminated with theconsequences described below.</p><p><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> The<i>_Exit</i>() and <i>_exit</i>() functions shall be functionally equivalent. <img src="../images/opt-end.gif" alt="[Option End]"border="0"></p><p>The <i>_Exit</i>() <sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;and <i>_exit</i>() <img src="../images/opt-end.gif" alt="[Option End]" border="0"> functionsshall not call functions registered with <a href="../functions/atexit.html"><i>atexit</i>()</a> nor any registered signal handlers.Whether open streams are flushed or closed, or temporary files are removed is implementation-defined. Finally, the calling processis terminated with the consequences described below.</p><p>These functions shall terminate the calling process <sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;with the following consequences: <img src="../images/opt-end.gif"alt="[Option End]" border="0"> <basefont size="2"></p><dl><dt><b>Note:</b></dt><dd>These consequences are all extensions to the ISO&nbsp;C standard and are not further CX shaded. However, XSI extensions areshaded.</dd></dl><basefont size="3"> <ul><li><p>All of the file descriptors, directory streams, <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;conversion descriptors, and message catalog descriptors <img src="../images/opt-end.gif" alt="[Option End]" border="0"> &nbsp;open in the calling process shall be closed.</p></li><li><p>If the parent process of the calling process is executing a <a href="../functions/wait.html"><i>wait</i>()</a> or <a href="../functions/waitpid.html"><i>waitpid</i>()</a>, <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;and has neither set its SA_NOCLDWAIT flag nor set SIGCHLD toSIG_IGN, <img src="../images/opt-end.gif" alt="[Option End]" border="0"> it shall be notified of the calling process' terminationand the low-order eight bits (that is, bits 0377) of <i>status</i> shall be made available to it. If the parent is not waiting, thechild's status shall be made available to it when the parent subsequently executes <a href="../functions/wait.html"><i>wait</i>()</a> or <a href="../functions/waitpid.html"><i>waitpid</i>()</a>.</p><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The semantics of the <a href="../functions/waitid.html"><i>waitid</i>()</a> function shall be equivalent to <a href="../functions/wait.html"><i>wait</i>()</a>. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></li><li><p>If the parent process of the calling process is not executing a <a href="../functions/wait.html"><i>wait</i>()</a> or <a href="../functions/waitpid.html"><i>waitpid</i>()</a>, <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;and has neither set its SA_NOCLDWAIT flag nor set SIGCHLD toSIG_IGN, <img src="../images/opt-end.gif" alt="[Option End]" border="0"> the calling process shall be transformed into a <i>zombieprocess</i>. A <i>zombie process</i> is an inactive process and it shall be deleted at some later time when its parent processexecutes <a href="../functions/wait.html"><i>wait</i>()</a> or <a href="../functions/waitpid.html"><i>waitpid</i>()</a>.</p><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The semantics of the <a href="../functions/waitid.html"><i>waitid</i>()</a> function shall be equivalent to <a href="../functions/wait.html"><i>wait</i>()</a>. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></li><li><p>Termination of a process does not directly terminate its children. The sending of a SIGHUP signal as described below indirectlyterminates children in some circumstances.</p></li><li><p>Either:</p><p>If the implementation supports the SIGCHLD signal, a SIGCHLD shall be sent to the parent process.</p><p>Or:</p><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">If the parent process has set its SA_NOCLDWAIT flag, or set SIGCHLD to SIG_IGN, the status shall be discarded, and the lifetime ofthe calling process shall end immediately. If SA_NOCLDWAIT is set, it is implementation-defined whether a SIGCHLD signal is sent tothe parent process. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></li><li><p>The parent process ID of all of the calling process' existing child processes and zombie processes shall be set to the processID of an implementation-defined system process. That is, these processes shall be inherited by a special system process.</p></li><li><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Each attached shared-memory segment is detached and the value of <i>shm_nattch</i> (see <a href="../functions/shmget.html"><i>shmget</i>()</a>) in the data structure associated with its shared memory ID shall be decremented by1. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></li><li><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">For each semaphore for which the calling process has set a <i>semadj</i> value (see <a href="semop.html"><i>semop</i>()</a> ), thatvalue shall be added to the <i>semval</i> of the specified semaphore. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></li><li><p>If the process is a controlling process, the SIGHUP signal shall be sent to each process in the foreground process group of thecontrolling terminal belonging to the calling process.</p></li><li><p>If the process is a controlling process, the controlling terminal associated with the session shall be disassociated from thesession, allowing it to be acquired by a new controlling process.</p></li><li><p>If the exit of the process causes a process group to become orphaned, and if any member of the newly-orphaned process group isstopped, then a SIGHUP signal followed by a SIGCONT signal shall be sent to each process in the newly-orphaned process group.</p></li><li><p><sup>[<a href="javascript:open_code('SEM')">SEM</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">All open named semaphores in the calling process shall be closed as if by appropriate calls to <a href="../functions/sem_close.html"><i>sem_close</i>()</a>. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></li><li><p><sup>[<a href="javascript:open_code('ML')">ML</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Anymemory locks established by the process via calls to <a href="../functions/mlockall.html"><i>mlockall</i>()</a> or <a href="../functions/mlock.html"><i>mlock</i>()</a> shall be removed. If locked pages in the address space of the calling process are alsomapped into the address spaces of other processes and are locked by those processes, the locks established by the other processesshall be unaffected by the call by this process to <i>_Exit</i>() or <i>_exit</i>(). <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></li><li><p><sup>[<a href="javascript:open_code('MF')">MF|SHM</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Memory mappings that were created in the process shall be unmapped before the process is destroyed. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></li><li><p><sup>[<a href="javascript:open_code('TYM')">TYM</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Any blocks of typed memory that were mapped in the calling process shall be unmapped, as if <a href="../functions/munmap.html"><i>munmap</i>()</a> was implicitly called to unmap them. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></li><li><p><sup>[<a href="javascript:open_code('MSG')">MSG</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">All open message queue descriptors in the calling process shall be closed as if by appropriate calls to <a href="../functions/mq_close.html"><i>mq_close</i>()</a>. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></li><li><p><sup>[<a href="javascript:open_code('AIO')">AIO</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Any outstanding cancelable asynchronous I/O operations may be canceled. Those asynchronous I/O operations that are not canceled

⌨️ 快捷键说明

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