.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk .\" .\" .\" %%%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 .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 2012 Akihiro MOTOKI .\" all rights reserved. .\" Translated 2012-05-04, Akihiro MOTOKI .\" .TH PTHREAD_SELF 3 2014\-05\-13 Linux "Linux Programmer's Manual" .SH 名前 pthread_self \- 呼び出したスレッドの ID を取得する .SH 書式 .nf \fB#include \fP \fBpthread_t pthread_self(void);\fP .sp \fI\-pthread\fP でコンパイルしてリンクする。 .fi .SH 説明 \fBpthread_self\fP() 関数は、呼び出したスレッドの ID を返す。 得られる ID は、このスレッドが作成された \fBpthread_create\fP(3) の 呼び出しで \fI*thread\fP で返されるのと同じ値である。 .SH 返り値 この関数は常に成功し、呼び出したスレッドの ID を返す。 .SH エラー この関数は常に成功する。 .SH 属性 .SS "マルチスレッディング (pthreads(7) 参照)" \fBpthread_self\fP() 関数はスレッドセーフである。 .SH 準拠 POSIX.1\-2001. .SH 注意 POSIX.1 では、スレッド ID を表現するのに使用する型は、 スレッド実装が完全に自由に選択してよいことになっている。 例えば、スレッド ID を表現するのに数値型を使っても構造体を使ってもよい。 そのため、移植性を確保しつつ、 C 言語の等価演算子 (\fB==\fP) を使って、 \fIpthread_t\fP 型の変数の比較を行うことはできない。 代わりに \fBpthread_equal\fP(3) を使うこと。 スレッド識別子はその内部構造を意識すべきではない。 pthreads 関数以外でスレッド ID を利用しようとした場合、 移植性がなくなり、どのような結果が得られるかも分からない。 スレッド ID の一意性が保証されるのは、あるプロセス内においてのみである。 終了したスレッドが join されたり、 切り離された (detached) スレッドが終了されたりした後は、 そのスレッド ID は再利用されることがある。 \fBpthread_self\fP() が返すスレッド ID は、 \fBgettid\fP(2) が返すカーネルスレッド ID とは違うものである。 .SH 関連項目 \fBpthread_create\fP(3), \fBpthread_equal\fP(3), \fBpthreads\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。