.\" Copyright (C) 2008 Michael Kerrisk .\" and Copyright 2003 Abhijit Menon-Sen .\" .\" %%%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 .\" .\" 2004-05-31, added tgkill, ahu, aeb .\" 2008-01-15 mtk -- rewrote DESCRIPTION .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 2003 Akihiro MOTOKI, all rights reserved. .\" Translated 2003-03-05, Akihiro MOTOKI .\" Updated 2005-02-28, Akihiro MOTOKI .\" .TH TKILL 2 2014\-12\-31 Linux "Linux Programmer's Manual" .SH 名前 tkill, tgkill \- スレッドにシグナルを送る .SH 書式 .nf \fBint tkill(int \fP\fItid\fP\fB, int \fP\fIsig\fP\fB);\fP .sp \fBint tgkill(int \fP\fItgid\fP\fB, int \fP\fItid\fP\fB, int \fP\fIsig\fP\fB);\fP .fi \fI注\fP: これらのシステムコールには、glibc のラッパー関数はない。「注意」の節を参照。 .SH 説明 \fBtgkill\fP() はスレッドグループ \fItgid\fP に属するスレッド ID が \fItid\fP のスレッドにシグナル \fIsig\fP を送る。 (これに対し、 \fBkill\fP(2) は一つのプロセス (すなわち、スレッドグループ) にまとめてシグナルを 送るのにだけ利用できる。 \fBkill\fP(2) で送信されたシグナルはプロセス内の任意のスレッドに配送される。) .\" FIXME Maybe say something about the following: .\" http://sourceware.org/bugzilla/show_bug.cgi?id=12889 .\" Rich Felker .\" There is a race condition in pthread_kill: it is possible that, .\" between the time pthread_kill reads the pid/tid from the target .\" thread descriptor and the time it makes the tgkill syscall, .\" the target thread terminates and the same tid gets assigned .\" to a new thread in the same process. .\" .\" (The tgkill syscall was designed to eliminate a similar race .\" condition in tkill, but it only succeeded in eliminating races .\" where the tid gets reused in a different process, and does not .\" help if the same tid gets assigned to a new thread in the .\" same process.) .\" .\" The only solution I can see is to introduce a mutex that ensures .\" that a thread cannot exit while pthread_kill is being called on it. .\" .\" Note that in most real-world situations, like almost all race .\" conditions, this one will be extremely rare. To make it .\" measurable, one could exhaust all but 1-2 available pid values, .\" possibly by lowering the max pid parameter in /proc, forcing .\" the same tid to be reused rapidly. \fBtkill\fP() はもう使われなくなった \fBtgkill\fP() の先祖である。 \fBtkill\fP() ではシグナルの送り先のスレッド ID しか指定できない。 そのため、スレッドが終了して、そのスレッド ID が再利用される場合に、 意図しないスレッドにシグナルが送られる可能性がある。 このシステムコールの使用は避けること。 これらはシステムコールへの直接のインターフェースであり、 スレッドライブラリ内部での使用を意図したものである。 .SH 返り値 成功した場合、0 が返される。エラーが発生した場合、\-1 が返され、 \fIerrno\fP が適切に設定される。 .SH エラー .TP \fBEINVAL\fP 指定されたスレッド ID、スレッドグループ ID、シグナルが不正であった。 .TP \fBEPERM\fP 許可がなかった。どのような許可が必要かについては、 \fBkill\fP(2) を参照のこと。 .TP \fBESRCH\fP 指定されたスレッドID (とスレッドグループID) を持つプロセスが存在しない。 .SH バージョン \fBtkill\fP() は Linux 2.4.19 / 2.5.4 以降でサポートされ、 \fBtgkill\fP() は Linux 2.5.75 で追加された。 .SH 準拠 \fBtkill\fP() と \fBtgkill\fP() は Linux 固有であり、 移植を想定したプログラムでは使用すべきではない。 .SH 注意 スレッドグループの説明については \fBclone\fP(2) の \fBCLONE_THREAD\fP の説明を参照のこと。 glibc はこれらのシステムコールに対するラッパー関数を提供していない。 \fBsyscall\fP(2) を使って呼び出すこと。 .SH 関連項目 \fBclone\fP(2), \fBgettid\fP(2), \fBkill\fP(2), \fBrt_sigqueueinfo\fP(2) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部である。 プロジェクトの説明とバグ報告に関する情報は \%http://www.kernel.org/doc/man\-pages/ に書かれている。