uTools-Manuals/docs/linux/setsid.html
2019-04-21 11:50:48 +08:00

19 lines
1.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1 id="setsid">setsid</h1>
<p>在新的会话中运行程序。</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>setsid命令</strong> 子进程从父进程继承了SessionID、进程组ID和打开的终端。子进程如果要脱离这些代码中可通过调用setsid来实现。而命令行或脚本中可以通过使用命令setsid来运行程序实现。setsid帮助一个进程脱离从父进程继承而来的已打开的终端、隶属进程组和隶属的会话。</p>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">setsid[options] &lt;program&gt; [arguments ...]</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">-c, --ctty 将控制终端设置为当前控制终端
-f, --fork 总是 fork
-w, --wait 等待程序退出,并使用相同的返回</code></pre>
<h3 id="实例">实例</h3>
<p>可见 setsid 的使用也是非常方便的,也只需在要处理的命令前加上 setsid 即可</p>
<pre><code class="language-bash">[root@root ~]# setsid ping www.ibm.com
[root@root ~]# ps -ef |grep www.ibm.com
root 31094 1 0 07:28 ? 00:00:00 ping www.ibm.com
root 31102 29217 0 07:29 pts/4 00:00:00 grep www.ibm.com
[root@root ~]#</code></pre>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->