.\" 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 .\" .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya .\" all rights reserved. .\" Translated Sat Mar 1 16:46:43 JST 1997 .\" by HANATAKA Shinya .\" Modified Mon May 5 19:43:49 JST 1997 .\" by HANATAKA Shinya .\" Updated & Modified Thu Feb 10 22:45:24 JST 2005 .\" by Yuichi SATO .\" .\"WORD: session セッション .\"WORD: process group ID プロセス・グループID .\"WORD: process group leader プロセス・グループ・リーダー .\" .TH SETSID 2 2008-12-03 "Linux" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O setsid \- creates a session and sets the process group ID setsid \- セッション (session) を作成し、プロセス・グループ ID を設定する .\"O .SH SYNOPSIS .SH 書式 .ad l .B #include .sp .B pid_t setsid(void); .br .ad b .\"O .SH DESCRIPTION .SH 説明 .\"O .BR setsid () .\"O creates a new session if the calling process is not a .\"O process group leader. .\"O The calling process is the leader of the new .\"O session, the process group leader of the new process group, and has no .\"O controlling tty. .\"O The process group ID and session ID of the calling .\"O process are set to the PID of the calling process. .\"O The calling process .\"O will be the only process in this new process group and in this new session. .BR setsid () は呼び出したプロセスがプロセス・グループ・リーダー (process group leader) でなければ、新しいセッションを作成する。 呼び出したプロセスは新しいセッションのリーダー、新しいプロセス・グループの プロセス・グループ・リーダーとなり、tty の制御を持たない。 呼び出したプロセスのプロセス・グループ ID とセッション ID には、 呼び出したプロセスの PID が設定される。呼び出したプロセスはこの 新しいプロセス・グループ、この新しいセッションの唯一のプロセスとなる。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O On success, the (new) session ID of the calling process is returned. .\"O On error, .\"O .I "(pid_t)\ \-1" .\"O is returned, and .\"O .I errno .\"O is set to indicate the error. 成功すると、呼び出したプロセスの (新しい) セッション ID が返される。 エラーの場合は、 .I "(pid_t)\ \-1" が返され、 .I error にエラーを示す値が設定される。 .\"O .SH ERRORS .SH エラー .TP .B EPERM .\"O The process group ID of any process equals the PID of the calling process. .\"O Thus, in particular, .\"O .BR setsid () .\"O fails if the calling process is already a process group leader. いずれかのプロセスのプロセス・グループ ID が、 呼び出したプロセスの PID と等しい。 これは、呼び出したプロセスが既にプロセス・リーダーの場合には .BR setsid () は失敗することを意味する。 .\"O .SH "CONFORMING TO" .SH 準拠 SVr4, POSIX.1-2001. .\"O .SH NOTES .SH 注意 .\"O A child created via .\"O .BR fork (2) .\"O inherits its parent's session ID. .\"O The session ID is preserved across an .\"O .BR execve (2). .BR fork (2) で作成された子プロセスは、親プロセスのセッション ID を継承する。 .BR execve (2) の前後でセッション ID は保存される。 .\"O A process group leader is a process with process group ID equal .\"O to its PID. .\"O In order to be sure that .\"O .BR setsid () .\"O will succeed, .\"O .BR fork (2) .\"O and .\"O .BR exit (2), .\"O and have the child do .\"O .BR setsid (). プロセス・グループ・リーダーとは、そのプロセスのプロセス・グループ ID が その PID に等しいプロセスである。 .BR setsid () を確実に成功させるためには、 .BR fork (2) して .BR exit (2) し、子プロセスで .BR setsid () を行なえば良い。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR getsid (2), .BR setpgid (2), .BR setpgrp (2), .BR tcgetsid (3), .BR credentials (7)