X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=draft%2Fman2%2Fsetpgid.2;h=fc19dd6eed9d0430f9a04c8688ec1c0166a0a551;hb=d2ef53db26313f7ff3780ba9e181109f37f04780;hp=9123051ec6002ea5fb7ebe4872a22bf6b9aed675;hpb=7e089fcc022461849bbc09437103cc337a88dd9c;p=linuxjm%2FLDP_man-pages.git diff --git a/draft/man2/setpgid.2 b/draft/man2/setpgid.2 index 9123051e..fc19dd6e 100644 --- a/draft/man2/setpgid.2 +++ b/draft/man2/setpgid.2 @@ -2,6 +2,7 @@ .\" and Copyright (C) 2007, Michael Kerrisk .\" All rights reserved. .\" +.\" %%%LICENSE_START(BSD_4_CLAUSE_UCB) .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -29,6 +30,7 @@ .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. +.\" %%%LICENSE_END .\" .\" @(#)getpgrp.2 6.4 (Berkeley) 3/10/91 .\" @@ -43,6 +45,12 @@ .\" 2007-07-25, mtk, fairly substantial rewrites and rearrangements .\" of text. .\" +.\"******************************************************************* +.\" +.\" This file was generated with po4a. Translate the source file. +.\" +.\"******************************************************************* +.\" .\" Japanese Version Copyright (c) 1997-1999 HANATAKA Shinya .\" all rights reserved. .\" Translated Sun Nov 21 18:54:10 JST 1999 @@ -52,63 +60,46 @@ .\" Updated 2007-09-25, Akihiro MOTOKI , LDP v2.64 .\" Updated 2010-04-23, Akihiro MOTOKI, LDP v3.24 .\" -.\"WORD: process group ¥×¥í¥»¥¹¥°¥ë¡¼¥× -.\"WORD: process group ID ¥×¥í¥»¥¹¥°¥ë¡¼¥× ID -.\"WORD: terminal üËö -.\"WORD: foreground ¥Õ¥©¥¢¥°¥é¥ó¥É -.\"WORD: block ÃæÃÇ(block) -.\"WORD: job control ¥¸¥ç¥Ö¡¦¥³¥ó¥È¥í¡¼¥ë -.\" -.TH SETPGID 2 2010-09-26 "Linux" "Linux Programmer's Manual" -.\"O .SH NAME -.SH ̾Á° -.\"O setpgid, getpgid, setpgrp, getpgrp \- set/get process group -setpgid, getpgid, setpgrp, getpgrp \- ¥×¥í¥»¥¹¥°¥ë¡¼¥×¤ÎÀßÄê/¼èÆÀ¤ò¹Ô¤¦ -.\"O .SH SYNOPSIS -.SH ½ñ¼° -.B #include +.TH SETPGID 2 2014\-01\-07 Linux "Linux Programmer's Manual" +.SH 名前 +setpgid, getpgid, setpgrp, getpgrp \- プロセスグループの設定/取得を行う +.SH 書式 +\fB#include \fP .sp -.BI "int setpgid(pid_t " pid ", pid_t " pgid ); +\fBint setpgid(pid_t \fP\fIpid\fP\fB, pid_t \fP\fIpgid\fP\fB);\fP .br -.BI "pid_t getpgid(pid_t " pid ); +\fBpid_t getpgid(pid_t \fP\fIpid\fP\fB);\fP .sp -.BR "pid_t getpgrp(void);" " /* POSIX.1 version */" +\fBpid_t getpgrp(void);\fP /* POSIX.1 version */ .br -.BI "pid_t getpgrp(pid_t " pid ");\ \ \ \ \ \ \ \ \ \ \ " -/* BSD version */ +\fBpid_t getpgrp(pid_t \fP\fIpid\fP\fB);\ \ \ \ \ \ \ \ \ \ \ \fP /* BSD version */ .sp -.BR "int setpgrp(void);" " /* System V version */" +\fBint setpgrp(void);\fP /* System V version */ .br -.BI "int setpgrp(pid_t " pid ", pid_t " pgid ");\ " -/* BSD version */ +\fBint setpgrp(pid_t \fP\fIpid\fP\fB, pid_t \fP\fIpgid\fP\fB);\ \fP /* BSD version */ .sp .in -4n -.\"O Feature Test Macro Requirements for glibc (see -.\"O .BR feature_test_macros (7)): -glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï -.RB ( feature_test_macros (7) -»²¾È): +glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp .ad l .PD 0 -.BR getpgid (): +\fBgetpgid\fP(): .RS 4 -_XOPEN_SOURCE\ >=\ 500 || -_XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED +_XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED .br -.\"O || /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200809L -|| /* glibc 2.12 °Ê¹ß: */ _POSIX_C_SOURCE\ >=\ 200809L +|| /* glibc 2.12 以降: */ _POSIX_C_SOURCE\ >=\ 200809L .RE .sp -.BR setpgrp "() (POSIX.1):" +\fBsetpgrp\fP() (POSIX.1): .nf _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED +.br + || /* glibc 2.19 以降: */ _BSD_SOURCE .fi .sp -.BR setpgrp "()\ (BSD)," -.BR getpgrp "()\ (BSD):" +\fBsetpgrp\fP()\ (BSD), \fBgetpgrp\fP()\ (BSD) [glibc 2.19 より前]: .nf _BSD_SOURCE && !\ (_POSIX_SOURCE || _POSIX_C_SOURCE || _XOPEN_SOURCE || @@ -116,420 +107,106 @@ _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED .fi .PD .ad -.\"O .SH DESCRIPTION -.SH ÀâÌÀ -.\"O All of these interfaces are available on Linux, -.\"O and are used for getting and setting the -.\"O process group ID (PGID) of a process. -.\"O The preferred, POSIX.1-specified ways of doing this are: -.\"O .BR getpgrp (void), -.\"O for retrieving the calling process's PGID; and -.\"O .BR setpgid (), -.\"O for setting a process's PGID. -¤³¤ì¤é¤Î¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤¹¤Ù¤Æ¤¬ Linux ¤ÇÍøÍѲÄǽ¤Ç¡¢ -¤³¤ì¤é¤ò»È¤Ã¤Æ¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥× ID (PGID) ¤Î -¼èÆÀ¤äÀßÄ꤬¤Ç¤­¤ë¡£ -¿ä¾©¤Î¡¢POSIX.1 ¤Çµ¬Äꤵ¤ì¤¿ÊýË¡¤Ç¤Ï¡¢ -.BR getpgrp (void) -¤Ç¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î PGID ¤ò¼èÆÀ¤·¡¢ -.BR setpgid () -¤ÇÀßÄꤹ¤ë¡£ +.SH 説明 +これらのインタフェースすべてが Linux で利用可能で、 これらを使ってプロセスのプロセスグループ ID (PGID) の 取得や設定ができる。 +推奨の、POSIX.1 で規定された方法では、 \fBgetpgrp\fP(void) で呼び出し元プロセスの PGID を取得し、 +\fBsetpgid\fP() で設定する。 -.\"O .BR setpgid () -.\"O sets the PGID of the process specified by -.\"O .I pid -.\"O to -.\"O .IR pgid . -.\"O If -.\"O .I pid -.\"O is zero, then the process ID of the calling process is used. -.\"O If -.\"O .I pgid -.\"O is zero, then the PGID of the process specified by -.\"O .I pid -.\"O is made the same as its process ID. -.BR setpgid () -¤Ï -.I pid -¤Ç»ØÄꤷ¤¿¥×¥í¥»¥¹¤Î PGID ¤Ë -.I pgid -¤òÀßÄꤹ¤ë¡£ -.I pid -¤¬¥¼¥í¤Ê¤é¤Ð¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹ ID ¤¬ pid ¤È¤·¤Æ»ÈÍѤµ¤ì¤ë¡£ -.I pgid -¤¬¥¼¥í¤Ê¤é¤Ð¡¢ -.I pid -¤Ç»ØÄꤵ¤ì¤¿¥×¥í¥»¥¹¤Î PGID ¤¬¤½¤Î¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹ ID ¤È -Ʊ¤¸¤ËÀßÄꤵ¤ì¤ë¡£ -.\"O If -.\"O .BR setpgid () -.\"O is used to move a process from one process -.\"O group to another (as is done by some shells when creating pipelines), -.\"O both process groups must be part of the same session (see -.\"O .BR setsid (2) -.\"O and -.\"O .BR credentials (7)). -.\"O In this case, -.\"O the \fIpgid\fP specifies an existing process group to be joined and the -.\"O session ID of that group must match the session ID of the joining process. -.BR setpgid () -¤ò¥×¥í¥»¥¹¤ò¤¢¤ë¥×¥í¥»¥¹¥°¥ë¡¼¥×¤«¤éÊ̤Υ°¥ë¡¼¥×¤Ø -°ÜÆ°¤¹¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë¾ì¹ç¤Ï (°ìÉô¤Î¥·¥§¥ë¤Ï¥Ñ¥¤¥×¥é¥¤¥ó¤òÀ¸À® -¤¹¤ë»þ¤Ë¤³¤ì¤ò¹Ô¤¦)¡¢Î¾Êý¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥×¤ÏƱ¤¸¥»¥Ã¥·¥ç¥ó¤Î -°ìÉô¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤ -.RB ( setsid (2) -¤È -.BR credentials (7) -»²¾È)¡£¤³¤Î¾ì¹ç¤Ï \fIpgid\fP ¤Ï»²²Ã¤¹¤Ù¤­´û¸¤Î -¥×¥í¥»¥¹¥°¥ë¡¼¥×¤ò»ØÄꤷ¡¢¤½¤Î¥»¥Ã¥·¥ç¥ó ID ¤Ï»²²Ã¤¹¤ë¥×¥í¥»¥¹¤Î -¥»¥Ã¥·¥ç¥ó ID ¤Ë°ìÃפ·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£ +\fBsetpgid\fP() は \fIpid\fP で指定したプロセスの PGID に \fIpgid\fP を設定する。 \fIpid\fP +がゼロならば、呼び出し元プロセスのプロセス ID が pid として使用される。 \fIpgid\fP がゼロならば、 \fIpid\fP で指定されたプロセスの +PGID がそのプロセスのプロセス ID と 同じに設定される。 \fBsetpgid\fP() をプロセスをあるプロセスグループから別のグループへ +移動するために使用する場合は (一部のシェルはパイプラインを生成 する時にこれを行う)、両方のプロセスグループは同じセッションの 一部でなければならない +(\fBsetsid\fP(2) と \fBcredentials\fP(7) 参照)。この場合は \fIpgid\fP は参加すべき既存の +プロセスグループを指定し、そのセッション ID は参加するプロセスの セッション ID に一致しなければならない。 -.\"O The POSIX.1 version of -.\"O .BR getpgrp (), -.\"O which takes no arguments, -.\"O returns the PGID of the calling process. -POSIX.1 ¥Ð¡¼¥¸¥ç¥ó¤Î -.BR getpgrp () -¤Ï°ú¤­¿ô¤ò°ì¤Ä¤â¤È¤é¤º¡¢ -¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î PGID ¤òÊÖ¤¹¡£ +POSIX.1 バージョンの \fBgetpgrp\fP() は引き数を一つもとらず、 呼び出し元プロセスの PGID を返す。 -.\"O .BR getpgid () -.\"O returns the PGID of the process specified by -.\"O .IR pid . -.\"O If -.\"O .I pid -.\"O is zero, the process ID of the calling process is used. -.\"O (Retrieving the PGID of a process other than the caller is rarely -.\"O necessary, and the POSIX.1 -.\"O .BR getpgrp () -.\"O is preferred for that task.) -.BR getpgid () -¤Ï -.I pid -¤Ç»ØÄꤵ¤ì¤¿¥×¥í¥»¥¹¤Î PGID ¤òÊÖ¤¹¡£ -.I pid -¤¬¥¼¥í¤Ê¤é¤Ð¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹ ID ¤¬ pid ¤È¤·¤Æ»ÈÍѤµ¤ì¤ë¡£ -(¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹°Ê³°¤Î¥×¥í¥»¥¹¤Î PGID ¤Î¼èÆÀ¤¬É¬Íפˤʤ뤳¤È¤Ï -¤á¤Ã¤¿¤Ë¤Ê¤¯¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î PGID ¤ò¼èÆÀ¤¹¤ë¤Ë¤Ï -POSIX.1 ¥Ð¡¼¥¸¥ç¥ó¤Î -.BR getpgrp () -¤ò»È¤¦¤Î¤¬Ë¾¤Þ¤·¤¤¡£) +\fBgetpgid\fP() は \fIpid\fP で指定されたプロセスの PGID を返す。 \fIpid\fP がゼロならば、呼び出し元プロセスのプロセス ID +が pid として使用される。 (呼び出し元プロセス以外のプロセスの PGID の取得が必要になることは めったになく、呼び出し元プロセスの PGID +を取得するには POSIX.1 バージョンの \fBgetpgrp\fP() を使うのが望ましい。) -.\"O The System V-style -.\"O .BR setpgrp (), -.\"O which takes no arguments, is equivalent to -.\"O .IR "setpgid(0,\ 0)" . -System V ¥Ð¡¼¥¸¥ç¥ó¤Î -.BR setpgrp () -¤Ï°ú¤­¿ô¤ò°ì¤Ä¤â¤È¤é¤º¡¢ -.I "setpgid(0,\ 0)" -¤ÈÅù²Á¤Ç¤¢¤ë¡£ +System V バージョンの \fBsetpgrp\fP() は引き数を一つもとらず、 \fIsetpgid(0,\ 0)\fP と等価である。 + +BSD 仕様の \fBsetpgrp\fP() は \fIpid\fP と \fIpgid\fP を引き数にとり、 以下を呼び出すラッパー関数である。 + + setpgid(pid, pgid) -.\"O The BSD-specific -.\"O .BR setpgrp () -.\"O call, which takes arguments -.\"O .I pid -.\"O and -.\"O .IR pgid , -.\"O is equivalent to -.\"O .IR "setpgid(pid, pgid)" . -BSD »ÅÍͤΠ-.BR setpgrp () -¤Ï -.I pid -¤È -.I pgid -¤ò°ú¤­¿ô¤Ë¤È¤ê¡¢ -.I "setpgid(pid, pgid)" -¤ÈÅù²Á¤Ç¤¢¤ë¡£ .\" The true BSD setpgrp() system call differs in allowing the PGID .\" to be set to arbitrary values, rather than being restricted to .\" PGIDs in the same session. +glibc 2.19 以降、 BSD 固有の \fBsetpgrp\fP() 関数はもはや \fI\fP では公開されない。 +この関数の呼び出しは上記の \fBsetpgid\fP() の呼び出しで置き換えるべきである。 + +BSD 仕様の \fBgetpgrp\fP() は \fIpid\fP だけを引き数にとり、 以下を呼び出すラッパー関数である。 + + getpgid(pid) -.\"O The BSD-specific -.\"O .BR getpgrp () -.\"O call, which takes a single -.\"O .I pid -.\"O argument, is equivalent to -.\"O .IR "getpgid(pid)" . -BSD »ÅÍͤΠ-.BR getpgrp () -¤Ï -.I pid -¤À¤±¤ò°ú¤­¿ô¤Ë¤È¤ê¡¢ -.I "getpgid(pid)" -¤ÈÅù²Á¤Ç¤¢¤ë¡£ -.\"O .SH "RETURN VALUE" -.SH ÊÖ¤êÃÍ -.\"O On success, -.\"O .BR setpgid () -.\"O and -.\"O .BR setpgrp () -.\"O return zero. -.\"O On error, \-1 is returned, and -.\"O .I errno -.\"O is set appropriately. -.BR setpgid () -¤È -.BR setpgrp () -¤ÏÀ®¸ù¤·¤¿¾ì¹ç¡¢¥¼¥í¤òÊÖ¤¹¡£¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤òÊÖ¤·¡¢ -.I errno -¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë¡£ +glibc 2.19 以降、 BSD 固有の \fBgetpgrp\fP() 関数はもはや \fI\fP では公開されない。 +この関数の呼び出しは、引き数を取らない POSIX.1 の \fBgetpgrp\fP() の呼び出し (呼び出し元の PGID +を取得する目的の場合)、もしくは上記の \fBgetpgid\fP() の呼び出しで置き換えるべきである。 +.SH 返り値 +\fBsetpgid\fP() と \fBsetpgrp\fP() は成功した場合、ゼロを返す。エラーの場合は \-1 を返し、 \fIerrno\fP +が適切に設定される。 -.\"O The POSIX.1 -.\"O .BR getpgrp () -.\"O always returns the PGID of the caller. -POSIX.1 ¥Ð¡¼¥¸¥ç¥ó¤Î -.BR getpgrp () -¤Ï¾ï¤Ë¸Æ¤Ó½Ð¤·¥×¥í¥»¥¹¤Î PGID ¤òÊÖ¤¹¡£ +POSIX.1 バージョンの \fBgetpgrp\fP() は常に呼び出しプロセスの PGID を返す。 -.\"O .BR getpgid (), -.\"O and the BSD-specific -.\"O .BR getpgrp () -.\"O return a process group on success. -.\"O On error, \-1 is returned, and -.\"O .I errno -.\"O is set appropriately. -.BR getpgid () -¤È BSD »ÅÍͤΠ-.BR getpgrp () -¤ÏÀ®¸ù¤·¤¿¾ì¹ç¥×¥í¥»¥¹¥°¥ë¡¼¥×¤òÊÖ¤¹¡£ -¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤òÊÖ¤·¡¢ -.I errno -¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë¡£ -.\"O .SH ERRORS -.SH ¥¨¥é¡¼ -.TP -.B EACCES -.\"O An attempt was made to change the process group ID -.\"O of one of the children of the calling process and the child had -.\"O already performed an -.\"O .BR execve (2) -.\"O .RB ( setpgid (), -.\"O .BR setpgrp ()). -¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î»Ò¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥× ID ¤òÊѹ¹¤·¤è¤¦¤È¤·¤¿¤¬¡¢ -¤¹¤Ç¤Ë¤½¤Î»Ò¥×¥í¥»¥¹¤Ï -.BR execve (2) -¤ò¼Â¹Ô¤·¤Æ¤¤¤¿¡£ -.RB ( setpgid (), -.BR setpgrp ()) -.TP -.B EINVAL -.\"O .I pgid -.\"O is less than 0 -.\"O .RB ( setpgid (), -.\"O .BR setpgrp ()). -.I pgid -¤¬ 0 ¤è¤ê¾®¤µ¤¤¡£ -.RB ( setpgid (), -.BR setpgrp ()) -.TP -.B EPERM -.\"O An attempt was made to move a process into a process group in a -.\"O different session, or to change the process -.\"O group ID of one of the children of the calling process and the -.\"O child was in a different session, or to change the process group ID of -.\"O a session leader -.\"O .RB ( setpgid (), -.\"O .BR setpgrp ()). -¥×¥í¥»¥¹¤ò°Û¤Ê¤ë¥»¥Ã¥·¥ç¥ó¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Ë°ÜÆ°¤µ¤»¤è¤¦¤È¤·¤¿¡£ -¤Þ¤¿¤Ï¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î»Ò¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥× ID ¤òÊѹ¹¤·¤è¤¦¤È -¤·¤¿¤¬¡¢¤½¤Î»Ò¥×¥í¥»¥¹¤ÏÊ̤Υ»¥Ã¥·¥ç¥ó¤À¤Ã¤¿¡£ -¤Þ¤¿¤Ï¥»¥Ã¥·¥ç¥ó¥ê¡¼¥À¡¼¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥× ID ¤òÊѹ¹¤·¤è¤¦¤È¤·¤¿¡£ -.RB ( setpgid (), -.BR setpgrp ()) -.TP -.B ESRCH -.\"O For -.\"O .BR getpgid (): -.BR getpgid () -¤Î¾ì¹ç: -.I pid -¤¬¤É¤Î¥×¥í¥»¥¹¤Ë¤â°ìÃפ·¤Ê¤¤¡£ -.\"O For -.\"O .BR setpgid (): -.\"O .I pid -.\"O is not the calling process and not a child of the calling process. -.BR setpgid () -¤Î¾ì¹ç: -.I pid -¤¬¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Ç¤Ï¤Ê¤¯¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î»Ò¥×¥í¥»¥¹¤Ç¤â¤Ê¤¤¡£ -.\"O .SH "CONFORMING TO" -.SH ½àµò -.\"O .BR setpgid () -.\"O and the version of -.\"O .BR getpgrp () -.\"O with no arguments -.\"O conform to POSIX.1-2001. -.BR setpgid () -¤È¡¢°ú¤­¿ô¤Ê¤·¥Ð¡¼¥¸¥ç¥ó¤Î -.BR getpgrp () -¤Ï POSIX.1-2001 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£ +\fBgetpgid\fP() と BSD 仕様の \fBgetpgrp\fP() は成功した場合プロセスグループを返す。 エラーの場合は \-1 を返し、 +\fIerrno\fP が適切に設定される。 +.SH エラー +.TP +\fBEACCES\fP +呼び出し元プロセスの子プロセスのプロセスグループ ID を変更しようとしたが、 すでにその子プロセスは \fBexecve\fP(2) を実行していた。 +(\fBsetpgid\fP(), \fBsetpgrp\fP()) +.TP +\fBEINVAL\fP +\fIpgid\fP が 0 より小さい。 (\fBsetpgid\fP(), \fBsetpgrp\fP()) +.TP +\fBEPERM\fP +プロセスを異なるセッションのプロセスグループに移動させようとした。 または呼び出し元プロセスの子プロセスのプロセスグループ ID を変更しようと +したが、その子プロセスは別のセッションだった。 またはセッションリーダーのプロセスグループ ID を変更しようとした。 (\fBsetpgid\fP(), +\fBsetpgrp\fP()) +.TP +\fBESRCH\fP +\fBgetpgid\fP() の場合: \fIpid\fP がどのプロセスにも一致しない。 \fBsetpgid\fP() の場合: \fIpid\fP +が呼び出し元のプロセスではなく、呼び出し元のプロセスの子プロセスでもない。 +.SH 準拠 +\fBsetpgid\fP() と、引き数なしバージョンの \fBgetpgrp\fP() は POSIX.1\-2001 に準拠している。 -.\"O POSIX.1-2001 also specifies -.\"O .BR getpgid () -.\"O and the version of -.\"O .BR setpgrp () -.\"O that takes no arguments. -POSIX.1-2001 ¤Ï¡¢ -.BR getpgid () -¤È¡¢°ú¤­¿ô¤Ê¤·¥Ð¡¼¥¸¥ç¥ó¤Î -.BR setpgrp () -¤âµ¬Äꤷ¤Æ¤¤¤ë¡£ -.\"O (POSIX.1-2008 marks this -.\"O .BR setpgrp () -.\"O specification as obsolete.) -POSIX.1-2008 ¤Ï¡¢¤³¤Î -.BR setpgrp () -¤Î»ÅÍͤòÇÑ»ßͽÄê¤È¤·¤Æ¤¤¤ë¡£ +POSIX.1\-2001 は、 \fBgetpgid\fP() と、引き数なしバージョンの \fBsetpgrp\fP() も規定している。 +POSIX.1\-2008 は、この \fBsetpgrp\fP() の仕様を廃止予定としている。 -.\"O The version of -.\"O .BR getpgrp () -.\"O with one argument and the version of -.\"O .BR setpgrp () -.\"O that takes two arguments derive from 4.2BSD, -.\"O and are not specified by POSIX.1. -°ú¤­¿ô 1 ¸Ä¥Ð¡¼¥¸¥ç¥ó¤Î -.BR getpgrp () -¤È°ú¤­¿ô 2 ¸Ä¥Ð¡¼¥¸¥ç¥ó¤Î -.BR setpgrp () -¤Ï 4.2BSD ¤ËͳÍ褷¡¢ -POSIX.1 ¤Ç¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤¡£ -.\"O .SH NOTES -.SH Ãí°Õ -.\"O A child created via -.\"O .BR fork (2) -.\"O inherits its parent's process group ID. -.\"O The PGID is preserved across an -.\"O .BR execve (2). -.BR fork (2) -¤ÇºîÀ®¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ï¡¢¿Æ¥×¥í¥»¥¹¤Î PGID -¤ò·Ñ¾µ¤¹¤ë¡£ -.BR execve (2) -¤ÎÁ°¸å¤Ç PGID ¤ÏÊݸ¤µ¤ì¤ë¡£ +引き数 1 個バージョンの \fBgetpgrp\fP() と引き数 2 個バージョンの \fBsetpgrp\fP() は 4.2BSD に由来し、 +POSIX.1 では規定されていない。 +.SH 注意 +\fBfork\fP(2) で作成された子プロセスは、親プロセスの PGID を継承する。 \fBexecve\fP(2) の前後で PGID は保存される。 -.\"O Each process group is a member of a session and each process is a -.\"O member of the session of which its process group is a member. -³Æ¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Ï¥»¥Ã¥·¥ç¥ó¤Î¥á¥ó¥Ð¡¼¤Ç¤¢¤ê¡¢³Æ¥×¥í¥»¥¹¤Ï -¤½¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥×¤¬½ê°¤·¤Æ¤¤¤ë¥»¥Ã¥·¥ç¥ó¤Î¥á¥ó¥Ð¡¼¤Ç¤¢¤ë¡£ +各プロセスグループはセッションのメンバーであり、各プロセスは そのプロセスグループが所属しているセッションのメンバーである。 -.\"O A session can have a controlling terminal. -.\"O At any time, one (and only one) of the process groups -.\"O in the session can be the foreground process group -.\"O for the terminal; -.\"O the remaining process groups are in the background. -.\"O If a signal is generated from the terminal (e.g., typing the -.\"O interrupt key to generate -.\"O .BR SIGINT ), -.\"O that signal is sent to the foreground process group. -.\"O (See -.\"O .BR termios (3) -.\"O for a description of the characters that generate signals.) -¥»¥Ã¥·¥ç¥ó¤ÏÀ©¸æüËö (controlling terminal) ¤ò»ý¤Ä¤³¤È¤¬¤Ç¤­¤ë¡£ -¤¤¤Ä¤Ç¤â¡¢¥»¥Ã¥·¥ç¥ó¤Ë½ê°¤¹¤ë¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Î°ì¤Ä (¤À¤±) ¤¬ -üËö¤Î¥Õ¥©¥¢¥°¥é¥ó¥É¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Ë¤Ê¤ë¤³¤È¤¬¤Ç¤­¡¢ -»Ä¤ê¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Ï¥Ð¥Ã¥¯¥°¥é¥¦¥ó¥É¤Ë¤Ê¤ë¡£ -üËö¤«¤é¥·¥°¥Ê¥ë¤¬À¸À®¤µ¤ì¤¿¾ì¹ç (Î㤨¤Ð¡¢ÃæÃÇ¥­¡¼¤òᤤ¤Æ -.B SIGINT -¤¬À¸À®¤µ¤ì¤ë¤Ê¤É)¡¢¤½¤Î¥·¥°¥Ê¥ë¤Ï¥Õ¥©¥¢¥°¥é¥¦¥ó¥É¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥× -¤ËÁ÷¤é¤ì¤ë -(¥·¥°¥Ê¥ë¤òÀ¸À®¤¹¤ëʸ»ú¤ÎÀâÌÀ¤Ï -.BR termios (3) -¤ò»²¾È)¡£ -.\"O Only the foreground process group may -.\"O .BR read (2) -.\"O from the terminal; -.\"O if a background process group tries to -.\"O .BR read (2) -.\"O from the terminal, then the group is sent a -.\"O .B SIGTSTP -.\"O signal, which suspends it. -.\"O The -.\"O .BR tcgetpgrp (3) -.\"O and -.\"O .BR tcsetpgrp (3) -.\"O functions are used to get/set the foreground -.\"O process group of the controlling terminal. -¥Õ¥©¥¢¥°¥é¥¦¥ó¥É¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥×¤À¤±¤¬Ã¼Ëö¤«¤é¤Î -.BR read (2) -¤¬¤Ç¤­¤ë¡£ -¥Ð¥Ã¥¯¥°¥é¥¦¥ó¥É¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥×¤¬Ã¼Ëö¤«¤é¤Î -.BR read (2) -¤ò¹Ô¤ª¤¦¤È¤·¤¿¾ì¹ç¡¢¤½¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Ë¤Ï¥·¥°¥Ê¥ë -.B SIGTSTP -¤¬Á÷¤é¤ì¡¢¤½¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Ï°ì»þÄä»ß (suspend) ¤¹¤ë¡£ -´Ø¿ô -.BR tcgetpgrp (3) -¤È -.BR tcsetpgrp (3) -¤ò»È¤¦¤È¡¢À©¸æüËö¤Î¥Õ¥©¥¢¥°¥é¥¦¥ó¥É¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥×¤ò -¼èÆÀ/ÀßÄê¤Ç¤­¤ë¡£ +セッションは制御端末 (controlling terminal) を持つことができる。 いつでも、セッションに所属するプロセスグループの一つ (だけ) +が 端末のフォアグランドのプロセスグループになることができ、 残りのプロセスグループはバックグラウンドになる。 端末からシグナルが生成された場合 +(例えば、中断キーを叩いて \fBSIGINT\fP が生成されるなど)、そのシグナルはフォアグラウンドのプロセスグループ に送られる +(シグナルを生成する文字の説明は \fBtermios\fP(3) を参照)。 フォアグラウンドのプロセスグループだけが端末からの \fBread\fP(2) +ができる。 バックグラウンドのプロセスグループが端末からの \fBread\fP(2) を行おうとした場合、そのプロセスグループにはシグナル +\fBSIGTTIN\fP が送られ、そのプロセスグループは一時停止 (suspend) する。 関数 \fBtcgetpgrp\fP(3) と +\fBtcsetpgrp\fP(3) を使うと、制御端末のフォアグラウンドのプロセスグループを 取得/設定できる。 -.\"O The -.\"O .BR setpgid () -.\"O and -.\"O .BR getpgrp () -.\"O calls are used by programs such as -.\"O .BR bash (1) -.\"O to create process groups in order to implement shell job control. -.BR setpgid () -¤È -.BR getpgrp () -¤Ï¡¢ -.BR bash (1) -¤Î¤è¤¦¤Ê¥×¥í¥°¥é¥à¤Ç¡¢¥·¥§¥ë¤Î¥¸¥ç¥ÖÀ©¸æ (job control) ¤Î¼ÂÁõ¤Î¤¿¤á¤Î -¥×¥í¥»¥¹¥°¥ë¡¼¥×¤òºîÀ®¤¹¤ë¤Î¤Ë»È¤ï¤ì¤ë¡£ +\fBsetpgid\fP() と \fBgetpgrp\fP() は、 \fBbash\fP(1) のようなプログラムで、シェルのジョブ制御 (job +control) の実装のための プロセスグループを作成するのに使われる。 -.\"O If a session has a controlling terminal, and the -.\"O .B CLOCAL -.\"O flag for that terminal is not set, -.\"O and a terminal hangup occurs, then the session leader is sent a -.\"O .BR SIGHUP . -.\"O If the session leader exits, then a -.\"O .B SIGHUP -.\"O signal will also be sent to each process in the foreground -.\"O process group of the controlling terminal. -¥»¥Ã¥·¥ç¥ó¤¬À©¸æüËö¤ò»ý¤Ã¤Æ¤¤¤Æ¡¢¤½¤ÎüËö¤ËÂФ·¤Æ -.B CLOCAL -¥Õ¥é¥°¤¬ÀßÄꤵ¤ì¤Æ¤ª¤é¤º¡¢Ã¼Ëö¤Î¥Ï¥ó¥°¥¢¥Ã¥×¤¬µ¯¤­¤¿¾ì¹ç¡¢ -¥»¥Ã¥·¥ç¥ó¡¦¥ê¡¼¥À¡¼¤Ë -.B SIGHUP -¤¬Á÷¤é¤ì¤ë¡£ -¥»¥Ã¥·¥ç¥ó¡¦¥ê¡¼¥À¡¼¤¬½ªÎ»¤·¤¿¾ì¹ç¤Ë¤Ï¡¢¤½¤ÎÀ©¸æüËö¤Î -¥Õ¥©¥¢¥°¥é¥ó¥É¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Ë½ê°¤¹¤ë³Æ¥×¥í¥»¥¹¤Ë¤â -.B SIGHUP -¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤ë¡£ +セッションが制御端末を持っていて、その端末に対して \fBCLOCAL\fP フラグが設定されておらず、端末のハングアップが起きた場合、 +セッション・リーダーに \fBSIGHUP\fP が送られる。 セッション・リーダーが終了した場合には、その制御端末の +フォアグランドのプロセスグループに所属する各プロセスにも \fBSIGHUP\fP シグナルが送られる。 -.\"O If the exit of the process causes a process group to become orphaned, -.\"O and if any member of the newly orphaned process group is stopped, then a -.\"O .B SIGHUP -.\"O signal followed by a -.\"O .B SIGCONT -.\"O signal will be sent to each process -.\"O in the newly orphaned process group. -¥×¥í¥»¥¹¤Î½ªÎ»¤Ë¤è¤Ã¤Æ¥×¥í¥»¥¹¥°¥ë¡¼¥×¤¬¸É»ù (orphaned) ¤Ë¤Ê¤Ã¤¿ºÝ¤Ë¡¢ -¤½¤Î¿·¤¿¤Ë¸É»ù¤Ë¤Ê¤Ã¤¿¥×¥í¥»¥¹¥°¥ë¡¼¥×¤ËÄä»ß¤·¤Æ¤¤¤ë¥á¥ó¥Ð¡¼¤¬¤¤¤ì¤Ð¡¢ -¤½¤Î¸É»ù¤Ë¤Ê¤Ã¤¿¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Ë°¤¹Á´¤Æ¤Î¥×¥í¥»¥¹¤Ë -.B SIGHUP -¥·¥°¥Ê¥ë¤Ë³¤±¤Æ -.B SIGCONT -¥·¥°¥Ê¥ë¤¬Á÷¤é¤ì¤ë¡£ .\" exit.3 refers to the following text: -.\"O An orphaned process group is one in which the parent of -.\"O every member of process group is either itself also a member -.\"O of the process group or is a member of a process group -.\"O in a different session (see also -.\"O .BR credentials (7)). -¸É»ù¤Ë¤Ê¤Ã¤¿ (orphaned) ¥×¥í¥»¥¹¥°¥ë¡¼¥×¤È¤Ï¡¢ -¤½¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥×¤ÎÁ´¤Æ¤Î¥á¥ó¥Ð¡¼¤Ë¤Ä¤¤¤Æ¡¢¥á¥ó¥Ð¡¼¤Î¿Æ¥×¥í¥»¥¹¤¬¡¢ -¿Æ¥×¥í¥»¥¹¼«¿È¤â¤½¤Î¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Î¥á¥ó¥Ð¡¼¤«¡¢ -Ê̤Υ»¥Ã¥·¥ç¥ó¤Ë°¤¹¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Î¥á¥ó¥Ð¡¼¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ë¤è¤¦¤Ê¡¢ -¥×¥í¥»¥¹¥°¥ë¡¼¥×¤Î¤³¤È¤Ç¤¢¤ë¡£ -.\"O .SH "SEE ALSO" -.SH ´ØÏ¢¹àÌÜ -.BR getuid (2), -.BR setsid (2), -.BR tcgetpgrp (3), -.BR tcsetpgrp (3), -.BR termios (3), -.BR credentials (7) +プロセスの終了によってプロセスグループが孤児 (orphaned) になった際に、 +その新たに孤児になったプロセスグループに停止しているメンバーがいれば、 その孤児になったプロセスグループに属す全てのプロセスに \fBSIGHUP\fP +シグナルに続けて \fBSIGCONT\fP シグナルが送られる。 孤児になった (orphaned) プロセスグループとは、 +そのプロセスグループの全てのメンバーについて、メンバーの親プロセスが、 親プロセス自身もそのプロセスグループのメンバーか、 +別のセッションに属すプロセスグループのメンバーのいずれかであるような、 プロセスグループのことである。 +.SH 関連項目 +\fBgetuid\fP(2), \fBsetsid\fP(2), \fBtcgetpgrp\fP(3), \fBtcsetpgrp\fP(3), \fBtermios\fP(3), +\fBcredentials\fP(7) +.SH この文書について +この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.63 の一部 +である。プロジェクトの説明とバグ報告に関する情報は +http://www.kernel.org/doc/man\-pages/ に書かれている。