.\" Copyright Michael Haardt (michael@cantor.informatik.rwth-aachen.de) .\" Sat Aug 27 20:43:50 MET DST 1994 .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, write to the Free .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, .\" USA. .\" .\" Modified Sun Sep 11 19:19:05 1994 .\" Modified Mon Mar 25 10:19:00 1996 (merged a few .\" tiny changes from a man page by Charles Livingston). .\" Modified Sun Jul 21 14:45:46 1996 .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH SETSID 2 2008\-12\-03 Linux "Linux Programmer's Manual" .SH 名前 setsid \- セッション (session) を作成し、プロセスグループ ID を設定する .SH 書式 .ad l \fB#include \fP .sp \fBpid_t setsid(void);\fP .br .ad b .SH 説明 \fBsetsid\fP() は呼び出したプロセスがプロセスグループ・リーダー (process group leader) でなければ、新しいセッションを作成する。 呼び出したプロセスは新しいセッションのリーダー、新しいプロセスグループの プロセスグループ・リーダーとなり、tty の制御を持たない。 呼び出したプロセスのプロセスグループ ID とセッション ID には、 呼び出したプロセスの PID が設定される。呼び出したプロセスはこの 新しいプロセスグループ、この新しいセッションの唯一のプロセスとなる。 .SH 返り値 成功すると、呼び出したプロセスの (新しい) セッション ID が返される。 エラーの場合は、 \fI(pid_t)\ \-1\fP が返され、 \fIerror\fP にエラーを示す値が設定される。 .SH エラー .TP \fBEPERM\fP いずれかのプロセスのプロセスグループ ID が、 呼び出したプロセスの PID と等しい。 これは、呼び出したプロセスが既にプロセスリーダーの場合には \fBsetsid\fP() は失敗することを意味する。 .SH 準拠 SVr4, POSIX.1\-2001. .SH 注意 \fBfork\fP(2) で作成された子プロセスは、親プロセスのセッション ID を継承する。 \fBexecve\fP(2) の前後でセッション ID は保存される。 プロセスグループ・リーダーとは、そのプロセスのプロセスグループ ID が その PID に等しいプロセスである。 \fBsetsid\fP() を確実に成功させるためには、 \fBfork\fP(2) して \fBexit\fP(2) し、子プロセスで \fBsetsid\fP() を行なえば良い。 .SH 関連項目 \fBgetsid\fP(2), \fBsetpgid\fP(2), \fBsetpgrp\fP(2), \fBtcgetsid\fP(3), \fBcredentials\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.41 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。