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

📄 posix_spawnp.html

📁 posix标准英文,html格式
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!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>posix_spawn</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="posix_spawn"></a> <a name="tag_03_427"></a><!-- posix_spawn --> <!--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_427_01"></a>NAME</h4><blockquote>posix_spawn, posix_spawnp - spawn a process (<b>ADVANCED REALTIME</b>)</blockquote><h4><a name="tag_03_427_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><div class="box"><code><tt><sup>[<a href="javascript:open_code('SPN')">SPN</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> #include &lt;<a href="../basedefs/spawn.h.html">spawn.h</a>&gt;<br><br> int posix_spawn(pid_t *restrict</tt> <i>pid</i><tt>, const char *restrict</tt> <i>path</i><tt>,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const posix_spawn_file_actions_t *</tt><i>file_actions</i><tt>,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const posix_spawnattr_t *restrict</tt> <i>attrp</i><tt>,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char *const</tt> <i>argv</i><tt>[restrict], char *const</tt> <i>envp</i><tt>[restrict]);<br> int posix_spawnp(pid_t *restrict</tt> <i>pid</i><tt>, const char *restrict</tt> <i>file</i><tt>,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const posix_spawn_file_actions_t *</tt><i>file_actions</i><tt>,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const posix_spawnattr_t *restrict</tt> <i>attrp</i><tt>,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char *const</tt> <i>argv</i><tt>[restrict], char * const</tt> <i>envp</i><tt>[restrict]);<img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div><tt><br></tt></blockquote><h4><a name="tag_03_427_03"></a>DESCRIPTION</h4><blockquote><p>The <i>posix_spawn</i>() and <i>posix_spawnp</i>() functions shall create a new process (child process) from the specifiedprocess image. The new process image shall be constructed from a regular executable file called the new process image file.</p><p>When a C program is executed as the result of this call, it shall be entered as a C-language function call as follows:</p><pre><tt>int main(int</tt> <i>argc</i><tt>, char *</tt><i>argv</i><tt>[]);</tt></pre><p>where <i>argc</i> is the argument count and <i>argv</i> is an array of character pointers to the arguments themselves. Inaddition, the following variable:</p><pre><tt>extern char **environ;</tt></pre><p>shall be initialized as a pointer to an array of character pointers to the environment strings.</p><p>The argument <i>argv</i> is an array of character pointers to null-terminated strings. The last member of this array shall be anull pointer and is not counted in <i>argc</i>. These strings constitute the argument list available to the new process image. Thevalue in <i>argv</i>[0] should point to a filename that is associated with the process image being started by the<i>posix_spawn</i>() or <i>posix_spawnp</i>() function.</p><p>The argument <i>envp</i> is an array of character pointers to null-terminated strings. These strings constitute the environmentfor the new process image. The environment array is terminated by a null pointer.</p><p>The number of bytes available for the child process' combined argument and environment lists is {ARG_MAX}. The implementationshall specify in the system documentation (see the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap02.html#tag_02">Chapter 2, Conformance</a>) whether any list overhead, such as length words, null terminators,pointers, or alignment bytes, is included in this total.</p><p>The <i>path</i> argument to <i>posix_spawn</i>() is a pathname that identifies the new process image file to execute.</p><p>The <i>file</i> parameter to <i>posix_spawnp</i>() shall be used to construct a pathname that identifies the new process imagefile. If the <i>file</i> parameter contains a slash character, the <i>file</i> parameter shall be used as the pathname for the newprocess image file. Otherwise, the path prefix for this file shall be obtained by a search of the directories passed as theenvironment variable <i>PATH</i> (see the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap08.html">Chapter 8, Environment Variables</a>). If this environment variable is not defined, the results ofthe search are implementation-defined.</p><p>If <i>file_actions</i> is a null pointer, then file descriptors open in the calling process shall remain open in the childprocess, except for those whose close-on- <i><a href="../functions/exec.html">exec</a></i> flag FD_CLOEXEC is set (see <a href="fcntl.html"><i>fcntl</i>()</a> ). For those file descriptors that remain open, all attributes of the corresponding open filedescriptions, including file locks (see <a href="fcntl.html"><i>fcntl</i>()</a> ), shall remain unchanged.</p><p>If <i>file_actions</i> is not NULL, then the file descriptors open in the child process shall be those open in the callingprocess as modified by the spawn file actions object pointed to by <i>file_actions</i> and the FD_CLOEXEC flag of each remainingopen file descriptor after the spawn file actions have been processed. The effective order of processing the spawn file actionsshall be:</p><ol><li><p>The set of open file descriptors for the child process shall initially be the same set as is open for the calling process. Allattributes of the corresponding open file descriptions, including file locks (see <a href="fcntl.html"><i>fcntl</i>()</a> ), shallremain unchanged.</p></li><li><p>The signal mask, signal default actions, and the effective user and group IDs for the child process shall be changed asspecified in the attributes object referenced by <i>attrp</i>.</p></li><li><p>The file actions specified by the spawn file actions object shall be performed in the order in which they were added to thespawn file actions object.</p></li><li><p>Any file descriptor that has its FD_CLOEXEC flag set (see <a href="fcntl.html"><i>fcntl</i>()</a> ) shall be closed.</p></li></ol><p>The <b>posix_spawnattr_t</b> spawn attributes object type is defined in <a href="../basedefs/spawn.h.html"><i>&lt;spawn.h&gt;</i></a>. It shall contain at least the attributes defined below.</p><p>If the POSIX_SPAWN_SETPGROUP flag is set in the <i>spawn-flags</i> attribute of the object referenced by <i>attrp</i>, and the<i>spawn-pgroup</i> attribute of the same object is non-zero, then the child's process group shall be as specified in the<i>spawn-pgroup</i> attribute of the object referenced by <i>attrp</i>.</p><p>As a special case, if the POSIX_SPAWN_SETPGROUP flag is set in the <i>spawn-flags</i> attribute of the object referenced by<i>attrp</i>, and the <i>spawn-pgroup</i> attribute of the same object is set to zero, then the child shall be in a new processgroup with a process group ID equal to its process ID.</p><p>If the POSIX_SPAWN_SETPGROUP flag is not set in the <i>spawn-flags</i> attribute of the object referenced by <i>attrp</i>, thenew child process shall inherit the parent's process group.</p><p><sup>[<a href="javascript:open_code('PS')">PS</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Ifthe POSIX_SPAWN_SETSCHEDPARAM flag is set in the <i>spawn-flags</i> attribute of the object referenced by <i>attrp</i>, butPOSIX_SPAWN_SETSCHEDULER is not set, the new process image shall initially have the scheduling policy of the calling process withthe scheduling parameters specified in the <i>spawn-schedparam</i> attribute of the object referenced by <i>attrp</i>.</p><p>If the POSIX_SPAWN_SETSCHEDULER flag is set in the <i>spawn-flags</i> attribute of the object referenced by <i>attrp</i>(regardless of the setting of the POSIX_SPAWN_SETSCHEDPARAM flag), the new process image shall initially have the scheduling policyspecified in the <i>spawn-schedpolicy</i> attribute of the object referenced by <i>attrp</i> and the scheduling parametersspecified in the <i>spawn-schedparam</i> attribute of the same object. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>The POSIX_SPAWN_RESETIDS flag in the <i>spawn-flags</i> attribute of the object referenced by <i>attrp</i> governs the effectiveuser ID of the child process. If this flag is not set, the child process shall inherit the parent process' effective user ID. Ifthis flag is set, the child process' effective user ID shall be reset to the parent's real user ID. In either case, if theset-user-ID mode bit of the new process image file is set, the effective user ID of the child process shall become that file'sowner ID before the new process image begins execution.</p><p>The POSIX_SPAWN_RESETIDS flag in the <i>spawn-flags</i> attribute of the object referenced by <i>attrp</i> also governs theeffective group ID of the child process. If this flag is not set, the child process shall inherit the parent process' effectivegroup ID. If this flag is set, the child process' effective group ID shall be reset to the parent's real group ID. In either case,if the set-group-ID mode bit of the new process image file is set, the effective group ID of the child process shall become thatfile's group ID before the new process image begins execution.</p><p>If the POSIX_SPAWN_SETSIGMASK flag is set in the <i>spawn-flags</i> attribute of the object referenced by <i>attrp</i>, thechild process shall initially have the signal mask specified in the <i>spawn-sigmask</i> attribute of the object referenced by<i>attrp</i>.</p><p>If the POSIX_SPAWN_SETSIGDEF flag is set in the <i>spawn-flags</i> attribute of the object referenced by <i>attrp</i>, thesignals specified in the <i>spawn-sigdefault</i> attribute of the same object shall be set to their default actions in the childprocess. Signals set to the default action in the parent process shall be set to the default action in the child process.</p><p>Signals set to be caught by the calling process shall be set to the default action in the child process.</p><p>Except for SIGCHLD, signals set to be ignored by the calling process image shall be set to be ignored by the child process,unless otherwise specified by the POSIX_SPAWN_SETSIGDEF flag being set in the <i>spawn-flags</i> attribute of the object referencedby <i>attrp</i> and the signals being indicated in the <i>spawn-sigdefault</i> attribute of the object referenced by<i>attrp</i>.</p><p>If the SIGCHLD signal is set to be ignored by the calling process, it is unspecified whether the SIGCHLD signal is set to beignored or to the default action in the child process, unless otherwise specified by the POSIX_SPAWN_SETSIGDEF flag being set inthe <i>spawn_flags</i> attribute of the object referenced by <i>attrp</i> and the SIGCHLD signal being indicated in the<i>spawn_sigdefault</i> attribute of the object referenced by <i>attrp</i>.</p><p>If the value of the <i>attrp</i> pointer is NULL, then the default values are used.</p>

⌨️ 快捷键说明

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