OSDN Git Service

296283463ac03dfb19938013b383567a3d02c1e2
[linuxjm/LDP_man-pages.git] / release / man2 / setpgid.2
1 .\" Copyright (c) 1983, 1991 Regents of the University of California.
2 .\" and Copyright (C) 2007, Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" All rights reserved.
4 .\"
5 .\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\"    notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in the
13 .\"    documentation and/or other materials provided with the distribution.
14 .\" 3. All advertising materials mentioning features or use of this software
15 .\"    must display the following acknowledgement:
16 .\"     This product includes software developed by the University of
17 .\"     California, Berkeley and its contributors.
18 .\" 4. Neither the name of the University nor the names of its contributors
19 .\"    may be used to endorse or promote products derived from this software
20 .\"    without specific prior written permission.
21 .\"
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" SUCH DAMAGE.
33 .\" %%%LICENSE_END
34 .\"
35 .\"     @(#)getpgrp.2   6.4 (Berkeley) 3/10/91
36 .\"
37 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
38 .\" Modified 1995-04-15 by Michael Chastain <mec@shell.portal.com>:
39 .\"   Added 'getpgid'.
40 .\" Modified 1996-07-21 by Andries Brouwer <aeb@cwi.nl>
41 .\" Modified 1996-11-06 by Eric S. Raymond <esr@thyrsus.com>
42 .\" Modified 1999-09-02 by Michael Haardt <michael@moria.de>
43 .\" Modified 2002-01-18 by Michael Kerrisk <mtk.manpages@gmail.com>
44 .\" Modified 2003-01-20 by Andries Brouwer <aeb@cwi.nl>
45 .\" 2007-07-25, mtk, fairly substantial rewrites and rearrangements
46 .\" of text.
47 .\"
48 .\"*******************************************************************
49 .\"
50 .\" This file was generated with po4a. Translate the source file.
51 .\"
52 .\"*******************************************************************
53 .TH SETPGID 2 2013\-07\-31 Linux "Linux Programmer's Manual"
54 .SH 名前
55 setpgid, getpgid, setpgrp, getpgrp \- プロセスグループの設定/取得を行う
56 .SH 書式
57 \fB#include <unistd.h>\fP
58 .sp
59 \fBint setpgid(pid_t \fP\fIpid\fP\fB, pid_t \fP\fIpgid\fP\fB);\fP
60 .br
61 \fBpid_t getpgid(pid_t \fP\fIpid\fP\fB);\fP
62 .sp
63 \fBpid_t getpgrp(void);\fP /* POSIX.1 version */
64 .br
65 \fBpid_t getpgrp(pid_t \fP\fIpid\fP\fB);\ \ \ \ \ \ \ \ \ \ \ \fP /* BSD version */
66 .sp
67 \fBint setpgrp(void);\fP /* System V version */
68 .br
69 \fBint setpgrp(pid_t \fP\fIpid\fP\fB, pid_t \fP\fIpgid\fP\fB);\ \fP /* BSD version */
70 .sp
71 .in -4n
72 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
73 .in
74 .sp
75 .ad l
76 .PD 0
77 \fBgetpgid\fP():
78 .RS 4
79 _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
80 .br
81 || /* glibc 2.12 以降: */ _POSIX_C_SOURCE\ >=\ 200809L
82 .RE
83 .sp
84 \fBsetpgrp\fP() (POSIX.1):
85 .nf
86     _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
87     _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
88 .fi
89 .sp
90 \fBsetpgrp\fP()\ (BSD), \fBgetpgrp\fP()\ (BSD):
91 .nf
92     _BSD_SOURCE &&
93         !\ (_POSIX_SOURCE || _POSIX_C_SOURCE || _XOPEN_SOURCE ||
94            _XOPEN_SOURCE_EXTENDED || _GNU_SOURCE || _SVID_SOURCE)
95 .fi
96 .PD
97 .ad
98 .SH 説明
99 これらのインタフェースすべてが Linux で利用可能で、 これらを使ってプロセスのプロセスグループ ID (PGID) の 取得や設定ができる。
100 推奨の、POSIX.1 で規定された方法では、 \fBgetpgrp\fP(void)  で呼び出し元プロセスの PGID を取得し、
101 \fBsetpgid\fP()  で設定する。
102
103 \fBsetpgid\fP()  は \fIpid\fP で指定したプロセスの PGID に \fIpgid\fP を設定する。 \fIpid\fP
104 がゼロならば、呼び出し元プロセスのプロセス ID が pid として使用される。 \fIpgid\fP がゼロならば、 \fIpid\fP で指定されたプロセスの
105 PGID がそのプロセスのプロセス ID と 同じに設定される。 \fBsetpgid\fP()  をプロセスをあるプロセスグループから別のグループへ
106 移動するために使用する場合は (一部のシェルはパイプラインを生成 する時にこれを行う)、両方のプロセスグループは同じセッションの 一部でなければならない
107 (\fBsetsid\fP(2)  と \fBcredentials\fP(7)  参照)。この場合は \fIpgid\fP は参加すべき既存の
108 プロセスグループを指定し、そのセッション ID は参加するプロセスの セッション ID に一致しなければならない。
109
110 POSIX.1 バージョンの \fBgetpgrp\fP()  は引き数を一つもとらず、 呼び出し元プロセスの PGID を返す。
111
112 \fBgetpgid\fP()  は \fIpid\fP で指定されたプロセスの PGID を返す。 \fIpid\fP がゼロならば、呼び出し元プロセスのプロセス ID
113 が pid として使用される。 (呼び出し元プロセス以外のプロセスの PGID の取得が必要になることは めったになく、呼び出し元プロセスの PGID
114 を取得するには POSIX.1 バージョンの \fBgetpgrp\fP()  を使うのが望ましい。)
115
116 System V バージョンの \fBsetpgrp\fP()  は引き数を一つもとらず、 \fIsetpgid(0,\ 0)\fP と等価である。
117
118 .\" The true BSD setpgrp() system call differs in allowing the PGID
119 .\" to be set to arbitrary values, rather than being restricted to
120 .\" PGIDs in the same session.
121 BSD 仕様の \fBsetpgrp\fP()  は \fIpid\fP と \fIpgid\fP を引き数にとり、 \fIsetpgid(pid, pgid)\fP
122 と等価である。
123
124 BSD 仕様の \fBgetpgrp\fP()  は \fIpid\fP だけを引き数にとり、 \fIgetpgid(pid)\fP と等価である。
125 .SH 返り値
126 \fBsetpgid\fP()  と \fBsetpgrp\fP()  は成功した場合、ゼロを返す。エラーの場合は \-1 を返し、 \fIerrno\fP
127 が適切に設定される。
128
129 POSIX.1 バージョンの \fBgetpgrp\fP()  は常に呼び出しプロセスの PGID を返す。
130
131 \fBgetpgid\fP()  と BSD 仕様の \fBgetpgrp\fP()  は成功した場合プロセスグループを返す。 エラーの場合は \-1 を返し、
132 \fIerrno\fP が適切に設定される。
133 .SH エラー
134 .TP 
135 \fBEACCES\fP
136 呼び出し元プロセスの子プロセスのプロセスグループ ID を変更しようとしたが、 すでにその子プロセスは \fBexecve\fP(2)  を実行していた。
137 (\fBsetpgid\fP(), \fBsetpgrp\fP())
138 .TP 
139 \fBEINVAL\fP
140 \fIpgid\fP が 0 より小さい。 (\fBsetpgid\fP(), \fBsetpgrp\fP())
141 .TP 
142 \fBEPERM\fP
143 プロセスを異なるセッションのプロセスグループに移動させようとした。 または呼び出し元プロセスの子プロセスのプロセスグループ ID を変更しようと
144 したが、その子プロセスは別のセッションだった。 またはセッションリーダーのプロセスグループ ID を変更しようとした。 (\fBsetpgid\fP(),
145 \fBsetpgrp\fP())
146 .TP 
147 \fBESRCH\fP
148 \fBgetpgid\fP()  の場合: \fIpid\fP がどのプロセスにも一致しない。 \fBsetpgid\fP()  の場合: \fIpid\fP
149 が呼び出し元のプロセスではなく、呼び出し元のプロセスの子プロセスでもない。
150 .SH 準拠
151 \fBsetpgid\fP()  と、引き数なしバージョンの \fBgetpgrp\fP()  は POSIX.1\-2001 に準拠している。
152
153 POSIX.1\-2001 は、 \fBgetpgid\fP()  と、引き数なしバージョンの \fBsetpgrp\fP()  も規定している。
154 POSIX.1\-2008 は、この \fBsetpgrp\fP()  の仕様を廃止予定としている。
155
156 引き数 1 個バージョンの \fBgetpgrp\fP()  と引き数 2 個バージョンの \fBsetpgrp\fP()  は 4.2BSD に由来し、
157 POSIX.1 では規定されていない。
158 .SH 注意
159 \fBfork\fP(2)  で作成された子プロセスは、親プロセスの PGID を継承する。 \fBexecve\fP(2)  の前後で PGID は保存される。
160
161 各プロセスグループはセッションのメンバーであり、各プロセスは そのプロセスグループが所属しているセッションのメンバーである。
162
163 A session can have a controlling terminal.  At any time, one (and only one)
164 of the process groups in the session can be the foreground process group for
165 the terminal; the remaining process groups are in the background.  If a
166 signal is generated from the terminal (e.g., typing the interrupt key to
167 generate \fBSIGINT\fP), that signal is sent to the foreground process group.
168 (See \fBtermios\fP(3)  for a description of the characters that generate
169 signals.)  Only the foreground process group may \fBread\fP(2)  from the
170 terminal; if a background process group tries to \fBread\fP(2)  from the
171 terminal, then the group is sent a \fBSIGTTIN\fP signal, which suspends it.
172 The \fBtcgetpgrp\fP(3)  and \fBtcsetpgrp\fP(3)  functions are used to get/set the
173 foreground process group of the controlling terminal.
174
175 \fBsetpgid\fP()  と \fBgetpgrp\fP()  は、 \fBbash\fP(1)  のようなプログラムで、シェルのジョブ制御 (job
176 control) の実装のための プロセスグループを作成するのに使われる。
177
178 セッションが制御端末を持っていて、その端末に対して \fBCLOCAL\fP フラグが設定されておらず、端末のハングアップが起きた場合、
179 セッション・リーダーに \fBSIGHUP\fP が送られる。 セッション・リーダーが終了した場合には、その制御端末の
180 フォアグランドのプロセスグループに所属する各プロセスにも \fBSIGHUP\fP シグナルが送られる。
181
182 .\" exit.3 refers to the following text:
183 プロセスの終了によってプロセスグループが孤児 (orphaned) になった際に、
184 その新たに孤児になったプロセスグループに停止しているメンバーがいれば、 その孤児になったプロセスグループに属す全てのプロセスに \fBSIGHUP\fP
185 シグナルに続けて \fBSIGCONT\fP シグナルが送られる。 孤児になった (orphaned) プロセスグループとは、
186 そのプロセスグループの全てのメンバーについて、メンバーの親プロセスが、 親プロセス自身もそのプロセスグループのメンバーか、
187 別のセッションに属すプロセスグループのメンバーのいずれかであるような、 プロセスグループのことである。
188 .SH 関連項目
189 \fBgetuid\fP(2), \fBsetsid\fP(2), \fBtcgetpgrp\fP(3), \fBtcsetpgrp\fP(3), \fBtermios\fP(3),
190 \fBcredentials\fP(7)
191 .SH この文書について
192 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
193 である。プロジェクトの説明とバグ報告に関する情報は
194 http://www.kernel.org/doc/man\-pages/ に書かれている。