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

📄 setsid.html

📁 posix标准英文,html格式
💻 HTML
字号:
<!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>setsid</title></head><body bgcolor="white"><basefont size="3"> <a name="setsid"></a> <a name="tag_03_667"></a><!-- setsid --> <!--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_667_01"></a>NAME</h4><blockquote>setsid - create session and set process group ID</blockquote><h4><a name="tag_03_667_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>#include &lt;<a href="../basedefs/unistd.h.html">unistd.h</a>&gt;<br><br> pid_t setsid(void);<br></tt></code></p></blockquote><h4><a name="tag_03_667_03"></a>DESCRIPTION</h4><blockquote><p>The <i>setsid</i>() function shall create a new session, if the calling process is not a process group leader. Upon return thecalling process shall be the session leader of this new session, shall be the process group leader of a new process group, andshall have no controlling terminal. The process group ID of the calling process shall be set equal to the process ID of the callingprocess. The calling process shall be the only process in the new process group and the only process in the new session.</p></blockquote><h4><a name="tag_03_667_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, <i>setsid</i>() shall return the value of the new process group ID of the calling process.Otherwise, it shall return (<b>pid_t</b>)-1 and set <i>errno</i> to indicate the error.</p></blockquote><h4><a name="tag_03_667_05"></a>ERRORS</h4><blockquote><p>The <i>setsid</i>() function shall fail if:</p><dl compact><dt>[EPERM]</dt><dd>The calling process is already a process group leader, or the process group ID of a process other than the calling processmatches the process ID of the calling process.</dd></dl></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_667_06"></a>EXAMPLES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_667_07"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_667_08"></a>RATIONALE</h4><blockquote><p>The <i>setsid</i>() function is similar to the <a href="../functions/setpgrp.html"><i>setpgrp</i>()</a> function of System V.System V, without job control, groups processes into process groups and creates new process groups via <a href="../functions/setpgrp.html"><i>setpgrp</i>()</a>; only one process group may be part of a login session.</p><p>Job control allows multiple process groups within a login session. In order to limit job control actions so that they can onlyaffect processes in the same login session, this volume of IEEE&nbsp;Std&nbsp;1003.1-2001 adds the concept of a session that iscreated via <i>setsid</i>(). The <i>setsid</i>() function also creates the initial process group contained in the session.Additional process groups can be created via the <a href="../functions/setpgid.html"><i>setpgid</i>()</a> function. A System Vprocess group would correspond to a POSIX System Interfaces session containing a single POSIX process group. Note that thisfunction requires that the calling process not be a process group leader. The usual way to ensure this is true is to create a newprocess with <a href="../functions/fork.html"><i>fork</i>()</a> and have it call <i>setsid</i>(). The <a href="../functions/fork.html"><i>fork</i>()</a> function guarantees that the process ID of the new process does not match any existingprocess group ID.</p></blockquote><h4><a name="tag_03_667_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_667_10"></a>SEE ALSO</h4><blockquote><p><a href="getsid.html"><i>getsid</i>()</a>, <a href="setpgid.html"><i>setpgid</i>()</a>, <a href="setpgrp.html"><i>setpgrp</i>()</a>, the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a>, <a href="../basedefs/unistd.h.html"><i>&lt;unistd.h&gt;</i></a></p></blockquote><h4><a name="tag_03_667_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 3. Included for alignment with the POSIX.1-1988 standard.</p></blockquote><h4><a name="tag_03_667_12"></a>Issue 6</h4><blockquote><p>In the SYNOPSIS, the optional include of the <a href="../basedefs/sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> header isremoved.</p><p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p><ul><li><p>The requirement to include <a href="../basedefs/sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> has been removed. Although <ahref="../basedefs/sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> was required for conforming implementations of previous POSIXspecifications, it was not required for UNIX applications.</p></li></ul></blockquote><div class="box"><em>End of informative text.</em></div><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX &reg; is a registered Trademark of The Open Group.<br>POSIX &reg; is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>

⌨️ 快捷键说明

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