.\" 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_DETACH 3 2008\-11\-27 Linux "Linux Programmer's Manual" .SH 名前 pthread_detach \- スレッドを切り離す (detach する) .SH 書式 .nf \fB#include \fP \fBint pthread_detach(pthread_t \fP\fIthread\fP\fB);\fP .fi .sp \fI\-pthread\fP を付けてコンパイルとリンクを行う。 .SH 説明 \fBpthread_detach\fP() 関数は \fIthread\fP で識別されるスレッドに detached (切り離された状態) という印を付ける。 detached 状態のスレッドが終了すると、 別のスレッドが終了されたスレッドを join しなくても、 そのスレッドのリソースは自動的に解放されてシステムに戻される。 すでに detach 状態のスレッドを detach しようとした場合に どのような結果となるかは規定されていない。 .SH 返り値 成功すると、\fBpthread_detach\fP() は 0 を返す。 エラーの場合、エラー番号を返す。 .SH エラー .TP \fBEINVAL\fP \fIthread\fP が join 可能なスレッドではない。 .TP \fBESRCH\fP ID が \fIthread\fP のスレッドが見つからなかった。 .SH 準拠 POSIX.1\-2001. .SH 注意 いったんスレッドを detached 状態にすると、 そのスレッドを \fBpthread_join\fP(3) で join したり、 もう一度 join 可能にしたりすることはできない。 \fBpthread_attr_setdetachstate\fP(3) を使って \fBpthread_create\fP(3) の \fIattr\fP 引き数の detached 属性を設定することで、 新しいスレッドを detached 状態で作成することができる。 detached 属性は、スレッドが終了した際のシステムの動作を決めるだけである。 プロセスが \fBexit\fP(3) を使って終了した場合に、そのスレッドが終了され なくなるようなことはない (なお、メインスレッドが return した場合も プロセスが \fBexit\fP(3) を使って終了した場合と全く同じである)。 アプリケーションが作成した各スレッドについて、そのスレッドが使用して いるシステムリソースを解放できるように、\fBpthread_join\fP(3) か \fBpthread_detach\fP() のどちらかを呼び出すべきである (ただし、プロセスが 終了するときには、全てのスレッドのリソースが解放される)。 .SH 例 以下の文は、呼び出したスレッド自身を detach する。 pthread_detach(pthread_self()); .SH 関連項目 \fBpthread_attr_setdetachstate\fP(3), \fBpthread_cancel\fP(3), \fBpthread_create\fP(3), \fBpthread_exit\fP(3), \fBpthread_join\fP(3), \fBpthreads\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。