OSDN Git Service

(split) LDP v3.30, v3.31 の定型的な変更内容を反映。
[linuxjm/LDP_man-pages.git] / draft / man2 / setsid.2
1 .\" Copyright Michael Haardt (michael@cantor.informatik.rwth-aachen.de)
2 .\"     Sat Aug 27 20:43:50 MET DST 1994
3 .\"
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
8 .\"
9 .\" The GNU General Public License's references to "object code"
10 .\" and "executables" are to be interpreted as the output of any
11 .\" document formatting or typesetting system, including
12 .\" intermediate and printed output.
13 .\"
14 .\" This manual is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 .\" GNU General Public License for more details.
18 .\"
19 .\" You should have received a copy of the GNU General Public
20 .\" License along with this manual; if not, write to the Free
21 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
22 .\" USA.
23 .\"
24 .\" Modified Sun Sep 11 19:19:05 1994 <faith@cs.unc.edu>
25 .\" Modified Mon Mar 25 10:19:00 1996 <aeb@cwi.nl> (merged a few
26 .\"    tiny changes from a man page by Charles Livingston).
27 .\" Modified Sun Jul 21 14:45:46 1996 <aeb@cwi.nl>
28 .\"
29 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
30 .\"         all rights reserved.
31 .\" Translated Sat Mar  1 16:46:43 JST 1997
32 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
33 .\" Modified Mon May  5 19:43:49 JST 1997
34 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
35 .\" Updated & Modified Thu Feb 10 22:45:24 JST 2005
36 .\"         by Yuichi SATO <ysato444@yahoo.co.jp>
37 .\"
38 .\"WORD:        session                 ¥»¥Ã¥·¥ç¥ó
39 .\"WORD:        process group ID        ¥×¥í¥»¥¹¡¦¥°¥ë¡¼¥×ID
40 .\"WORD:        process group leader    ¥×¥í¥»¥¹¡¦¥°¥ë¡¼¥×¡¦¥ê¡¼¥À¡¼
41 .\"
42 .TH SETSID 2 2008-12-03 "Linux" "Linux Programmer's Manual"
43 .\"O .SH NAME
44 .SH Ì¾Á°
45 .\"O setsid \- creates a session and sets the process group ID
46 setsid \- ¥»¥Ã¥·¥ç¥ó (session) ¤òºîÀ®¤·¡¢¥×¥í¥»¥¹¡¦¥°¥ë¡¼¥× ID ¤òÀßÄꤹ¤ë
47 .\"O .SH SYNOPSIS
48 .SH ½ñ¼°
49 .ad l
50 .B #include <unistd.h>
51 .sp
52 .B pid_t setsid(void);
53 .br
54 .ad b
55 .\"O .SH DESCRIPTION
56 .SH ÀâÌÀ
57 .\"O .BR setsid ()
58 .\"O creates a new session if the calling process is not a
59 .\"O process group leader.
60 .\"O The calling process is the leader of the new
61 .\"O session, the process group leader of the new process group, and has no
62 .\"O controlling tty.
63 .\"O The process group ID and session ID of the calling
64 .\"O process are set to the PID of the calling process.
65 .\"O The calling process
66 .\"O will be the only process in this new process group and in this new session.
67 .BR setsid ()
68 ¤Ï¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤¬¥×¥í¥»¥¹¡¦¥°¥ë¡¼¥×¡¦¥ê¡¼¥À¡¼
69 (process group leader) ¤Ç¤Ê¤±¤ì¤Ð¡¢¿·¤·¤¤¥»¥Ã¥·¥ç¥ó¤òºîÀ®¤¹¤ë¡£
70 ¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Ï¿·¤·¤¤¥»¥Ã¥·¥ç¥ó¤Î¥ê¡¼¥À¡¼¡¢¿·¤·¤¤¥×¥í¥»¥¹¡¦¥°¥ë¡¼¥×¤Î
71 ¥×¥í¥»¥¹¡¦¥°¥ë¡¼¥×¡¦¥ê¡¼¥À¡¼¤È¤Ê¤ê¡¢tty ¤ÎÀ©¸æ¤ò»ý¤¿¤Ê¤¤¡£
72 ¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹¡¦¥°¥ë¡¼¥× ID ¤È¥»¥Ã¥·¥ç¥ó ID ¤Ë¤Ï¡¢
73 ¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î PID ¤¬ÀßÄꤵ¤ì¤ë¡£¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Ï¤³¤Î
74 ¿·¤·¤¤¥×¥í¥»¥¹¡¦¥°¥ë¡¼¥×¡¢¤³¤Î¿·¤·¤¤¥»¥Ã¥·¥ç¥ó¤ÎÍ£°ì¤Î¥×¥í¥»¥¹¤È¤Ê¤ë¡£
75 .\"O .SH "RETURN VALUE"
76 .SH ÊÖ¤êÃÍ
77 .\"O On success, the (new) session ID of the calling process is returned.
78 .\"O On error,
79 .\"O .I "(pid_t)\ \-1"
80 .\"O is returned, and
81 .\"O .I errno
82 .\"O is set to indicate the error.
83 À®¸ù¤¹¤ë¤È¡¢¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î (¿·¤·¤¤) ¥»¥Ã¥·¥ç¥ó ID ¤¬ÊÖ¤µ¤ì¤ë¡£
84 ¥¨¥é¡¼¤Î¾ì¹ç¤Ï¡¢
85 .I "(pid_t)\ \-1"
86 ¤¬ÊÖ¤µ¤ì¡¢
87 .I error
88 ¤Ë¥¨¥é¡¼¤ò¼¨¤¹Ãͤ¬ÀßÄꤵ¤ì¤ë¡£
89 .\"O .SH ERRORS
90 .SH ¥¨¥é¡¼
91 .TP
92 .B EPERM
93 .\"O The process group ID of any process equals the PID of the calling process.
94 .\"O Thus, in particular,
95 .\"O .BR setsid ()
96 .\"O fails if the calling process is already a process group leader.
97 ¤¤¤º¤ì¤«¤Î¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹¡¦¥°¥ë¡¼¥× ID ¤¬¡¢
98 ¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î PID ¤ÈÅù¤·¤¤¡£
99 ¤³¤ì¤Ï¡¢¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤¬´û¤Ë¥×¥í¥»¥¹¡¦¥ê¡¼¥À¡¼¤Î¾ì¹ç¤Ë¤Ï
100 .BR setsid ()
101 ¤Ï¼ºÇÔ¤¹¤ë¤³¤È¤ò°ÕÌ£¤¹¤ë¡£
102 .\"O .SH "CONFORMING TO"
103 .SH ½àµò
104 SVr4, POSIX.1-2001.
105 .\"O .SH NOTES
106 .SH Ãí°Õ
107 .\"O A child created via
108 .\"O .BR fork (2)
109 .\"O inherits its parent's session ID.
110 .\"O The session ID is preserved across an
111 .\"O .BR execve (2).
112 .BR fork (2)
113 ¤ÇºîÀ®¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ï¡¢¿Æ¥×¥í¥»¥¹¤Î¥»¥Ã¥·¥ç¥ó ID ¤ò·Ñ¾µ¤¹¤ë¡£
114 .BR execve (2)
115 ¤ÎÁ°¸å¤Ç¥»¥Ã¥·¥ç¥ó ID ¤ÏÊݸ¤µ¤ì¤ë¡£
116
117 .\"O A process group leader is a process with process group ID equal
118 .\"O to its PID.
119 .\"O In order to be sure that
120 .\"O .BR setsid ()
121 .\"O will succeed,
122 .\"O .BR fork (2)
123 .\"O and
124 .\"O .BR exit (2),
125 .\"O and have the child do
126 .\"O .BR setsid ().
127 ¥×¥í¥»¥¹¡¦¥°¥ë¡¼¥×¡¦¥ê¡¼¥À¡¼¤È¤Ï¡¢¤½¤Î¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹¡¦¥°¥ë¡¼¥× ID ¤¬
128 ¤½¤Î PID ¤ËÅù¤·¤¤¥×¥í¥»¥¹¤Ç¤¢¤ë¡£
129 .BR setsid ()
130 ¤ò³Î¼Â¤ËÀ®¸ù¤µ¤»¤ë¤¿¤á¤Ë¤Ï¡¢
131 .BR fork (2)
132 ¤·¤Æ
133 .BR exit (2)
134 ¤·¡¢»Ò¥×¥í¥»¥¹¤Ç
135 .BR setsid ()
136 ¤ò¹Ô¤Ê¤¨¤ÐÎɤ¤¡£
137 .\"O .SH "SEE ALSO"
138 .SH ´ØÏ¢¹àÌÜ
139 .BR getsid (2),
140 .BR setpgid (2),
141 .BR setpgrp (2),
142 .BR tcgetsid (3),
143 .BR credentials (7)