killpgのヘルプ・マニュアル
日本語 英語
killpg --help
man killpg
KILLPG(2) Linux Programmer’s Manual KILLPG(2)
名前
killpg - シグナルをプロセス・グループに送る
書式
#include
int killpg(int pgrp, int sig);
glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):
killpg(): _BSD_SOURCE || _XOPEN_SOURCE >= 500
説明
killpg() は sig で指定したシグナルを pgrp で指定したプロセス・グループ
に送る。シグナルの定義の一覧は signal(7) を参照のこと。
引き数 pgrp に 0 を指定した場合には killpg() は呼び出し元のプロセスが属
し ているプロセス・グループに対してシグナルを送る。 (POSIX では以下のよ
うに記述されている: pgrp が 1 以下である場合、動作は未定義である。)
プロセスがシグナルを送信する許可を持つためには、プロセスが特 権 (Linux
では CAP_KILL ケーパビリティ (capability)) を持つか、送信元プロセスの実
ユーザー ID または実効ユーザー ID が送信先プロセスの実 set-user-ID また
は 保存 set-user-ID と等しくなければならない。 SIGCONT の場合、送信プロ
セスと受信プロセスが同じセッションに属していれば十分である。
返り値
正常終了すると 0 が返り値となる。異常終了の場合 -1 が返り値となり errno
に原因コードが設定される。
エラー
EINVAL sig で指定された値は無効なシグナル番号である。
EPERM プロセスに何れかの送信先プロセスにシグナルを送信する許可がない。
ESRCH pgrp で指定されたプロセス・グループに属するプロセスが存在しな か
った。
ESRCH プロセス・グループとして 0 が指定されたが、送信プロセスはプロセ
ス・グループを持っていない。
準拠
SVr4, 4.4BSD (killpg() は 4BSD で初めて追加された), POSIX.1-2001。
注意
BSD 系システムと System V 系システムでは、許可のチェックに様々な違い が
あ る 。 kill(2) についての POSIX の原理 (rationale) を参照すること。
POSIX で記述されていない違いとしては、返り値 EPERM がある。 BSD では 「
送信先プロセスの許可のチェックが 1 つでも失敗した場合は、シグナルが送信
されず、 EPERM が返される」と記述されている。 POSIX では「送信先プロ セ
スの許可のチェックが全て失敗した場合にのみ、 EPERM が返される」と記述さ
れている。
Linux では、 killpg() はライブラリ関数 と し て 実 装 さ れ て お り 、
kill(-pgrp, sig) の呼び出しが行われる。
関連項目
getpgrp(2), kill(2), signal(2), credentials(7), capabilities(7)
Linux 2007-07-26 KILLPG(2)
KILLPG(2) Linux Programmer’s Manual KILLPG(2)
NAME
killpg - send signal to a process group
SYNOPSIS
#include
int killpg(int pgrp, int sig);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
killpg(): _BSD_SOURCE || _XOPEN_SOURCE >= 500
DESCRIPTION
killpg() sends the signal sig to the process group pgrp. See signal(7)
for a list of signals.
If pgrp is 0, killpg() sends the signal to the calling process’s pro-
cess group. (POSIX says: If pgrp is less than or equal to 1, the
behavior is undefined.)
For a process to have permission to send a signal it must either be
privileged (under Linux: have the CAP_KILL capability), or the real or
effective user ID of the sending process must equal the real or saved
set-user-ID of the target process. In the case of SIGCONT it suffices
when the sending and receiving processes belong to the same session.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is
set appropriately.
ERRORS
EINVAL Sig is not a valid signal number.
EPERM The process does not have permission to send the signal to any
of the target processes.
ESRCH No process can be found in the process group specified by pgrp.
ESRCH The process group was given as 0 but the sending process does
not have a process group.
CONFORMING TO
SVr4, 4.4BSD (the killpg() function call first appeared in 4BSD),
POSIX.1-2001.
NOTES
There are various differences between the permission checking in BSD-
type systems and System V-type systems. See the POSIX rationale for
kill(). A difference not mentioned by POSIX concerns the return value
EPERM: BSD documents that no signal is sent and EPERM returned when the
permission check failed for at least one target process, while POSIX
documents EPERM only when the permission check failed for all target
processes.
On Linux, killpg() is implemented as a library function that makes the
call kill(-pgrp, sig).
SEE ALSO
getpgrp(2), kill(2), signal(2), capabilities(7), credentials(7)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2007-07-26 KILLPG(2)