.\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992 .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" Modified by Michael Haardt .\" Modified by Thomas Koenig .\" Modified 1993-07-23 by Rik Faith .\" Modified 1993-07-25 by Rik Faith .\" Modified 1995-11-01 by Michael Haardt .\" .\" Modified 1996-04-14 by Andries Brouwer .\" [added some polishing contributed by Mike Battersby ] .\" Modified 1996-07-21 by Andries Brouwer .\" Modified 1997-01-17 by Andries Brouwer .\" Modified 2001-12-18 by Andries Brouwer .\" Modified 2002-07-24 by Michael Kerrisk .\" Added note on historical rules enforced when an unprivileged process .\" sends a signal. .\" Modified 2004-06-16 by Michael Kerrisk .\" Added note on CAP_KILL .\" Modified 2004-06-24 by aeb .\" Modified, 2004-11-30, after idea from emmanuel.colbus@ensimag.imag.fr .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 Kazuyuki Tanisako .\" all rights reserved. .\" Translated 1997-05-17, Kazuyuki Tanisako .\" Modified 1997-05-27, Kazuyuki Tanisako .\" Modified 1998-02-05, Kazuyuki Tanisako .\" Updated 2001-12-27, Kentaro Shirakata .\" Updated 2002-01-03, Kentaro Shirakata .\" Updated 2002-09-27, Kentaro Shirakata .\" Updated 2005-02-27, Akihiro MOTOKI .\" Updated 2005-12-05, Akihiro MOTOKI, Catch up to LDP man-pages 2.16 .\" Updated 2008-08-06, Akihiro MOTOKI, LDP v3.05 .\" .TH KILL 2 2019\-10\-10 Linux "Linux Programmer's Manual" .SH 名前 kill \- プロセスにシグナルを送る .SH 書式 .nf \fB#include \fP \fB#include \fP .PP \fBint kill(pid_t \fP\fIpid\fP\fB, int \fP\fIsig\fP\fB);\fP .fi .PP .RS -4 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .RE .PP .ad l \fBkill\fP(): _POSIX_C_SOURCE .ad b .SH 説明 システムコールの \fBkill\fP() は、任意のプロセスグループもしくはプロセスにシグナルを 送るのに使われる。 .PP \fIpid\fP に正の値を指定した場合、シグナル \fIsig\fP が \fIpid\fP で指定された ID を持つプロセスに送られる。 .PP \fIpid\fP に 0 を指定した場合、 呼び出し元のプロセスのプロセスグループに属するすべてのプロセスに \fIsig\fP で指定したシグナルが送られる。 .PP \fIpid\fP に \-1 を指定した場合、 \fIsig\fP で指定したシグナルが、 呼び出し元のプロセスがシグナルを送る許可を持つ全てのプロセスに 送られる。但し、プロセス番号 1 (\fIinit\fP) へはシグナルは送られない。 以下の関連部分も参照のこと。 .PP \fIpid\fP に \-1 より小さな値を指定した場合、 ID が \fI\-pid\fP のプロセスグループに属するすべてのプロセスに \fIsig\fP で指定したシグナルが送られる。 .PP If \fIsig\fP is 0, then no signal is sent, but existence and permission checks are still performed; this can be used to check for the existence of a process ID or process group ID that the caller is permitted to signal. .PP For a process to have permission to send a signal, it must either be privileged (under Linux: have the \fBCAP_KILL\fP capability in the user namespace of the target process), 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 \fBSIGCONT\fP, it suffices when the sending and receiving processes belong to the same session. (Historically, the rules were different; see NOTES.) .SH 返り値 成功した場合 (少なくとも一つのシグナルが送信された場合)、 0 が返される。エラーの場合 \-1 が返され、 \fIerrno\fP が適切に設定される。 .SH エラー .TP \fBEINVAL\fP 無効なシグナルを指定した。 .TP \fBEPERM\fP 呼び出し元のプロセスが、受信するプロセスのいずれに対しても シグナルを送る許可を持っていない。 .TP \fBESRCH\fP The target process or process group does not exist. Note that an existing process might be a zombie, a process that has terminated execution, but has not yet been \fBwait\fP(2)ed for. .SH 準拠 POSIX.1\-2001, POSIX.1\-2008, SVr4, 4.3BSD. .SH 注意 プロセス番号 1 の \fIinit\fP プロセスに送ることができるシグナルは、 \fIinit\fP が明示的にシグナルハンドラーを設定したシグナルだけである。 こうなっているのは、誤ってシステムをダウンさせないようにするためである。 .PP POSIX.1 では、 \fIkill(\-1,sig)\fP が 呼び出し元のプロセスがシグナルを送ることが出来るプロセス全てに \fIsig\fP を送ることを要求している。 但し、システム実装時に定められたシステムプロセスは シグナルの送信対象から除外される。 Linux では、プロセスが自分自身にシグナルを送れるようになっているが、 Linux の \fIkill(\-1,sig)\fP は呼び出し元のプロセスにはシグナルを送らない。 .PP POSIX.1 では以下の動作になることを要求している。 自分自身にシグナルを送ると、シグナルを送ったスレッドがそのシグナルをブロック しておらず、他のどのスレッドもそのシグナルを受ける状態にもなく \fBsigwait\fP(3) でそのシグナルを待ってもいない場合、 \fBkill\fP() が返る前に少なくとも一つのブロックされていない シグナルがシグナルを送ったスレッドに配送されなければならない。 .SS "Linux での注意" .\" In the 0.* kernels things chopped and changed quite .\" a bit - MTK, 24 Jul 02 Linux では、特権のないプロセスが他のプロセスにシグナルを送信するために必要な権限についてのルールが、カーネルバージョンにより違っている。 カーネル 1.0 から 1.2.2 では、送信側の実効ユーザー ID が送信対象の実効ユーザー ID と一致するか、 送信側の実ユーザー ID が送信対象の実ユーザー ID と一致すれば、 シグナルを送信できた。 カーネル 1.2.3 から 1.3.77では、送信側の実効ユーザー ID が送信対象の実ユーザー ID か実効ユーザー ID のいずれかと一致すればシグナルを送信できた。 現在のルールは、POSIX.1 に準拠しており、カーネル 1.3.78 以降で 適用されている。 .SH バグ バージョン 2.6.7 以前の 2.6 系のカーネルには、 プロセスグループにシグナルを送ったときに、 呼び出し元のプロセスがプロセスグループの (全メンバーではなく) 一部のメンバーに対してのみシグナルを送る許可を持っていない場合に、 \fBkill\fP() がエラー \fBEPERM\fP で失敗するというバグがある。 このエラーが返るにもかかわらず、そのシグナルは呼び出し元が シグナルを送る許可を持つ全てのプロセスへ送られる。 .SH 関連項目 \fBkill\fP(1), \fB_exit\fP(2), \fBpidfd_send_signal\fP(2), \fBsignal\fP(2), \fBtkill\fP(2), \fBexit\fP(3), \fBkillpg\fP(3), \fBsigqueue\fP(3), \fBcapabilities\fP(7), \fBcredentials\fP(7), \fBsignal\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。