.\" 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_TRYJOIN_NP 3 2020\-12\-21 Linux "Linux Programmer's Manual" .SH 名前 pthread_tryjoin_np, pthread_timedjoin_np \- 終了したスレッドの join を 試みる .SH 書式 .nf \fB#define _GNU_SOURCE\fP /* See feature_test_macros(7) */ \fB#include \fP .PP \fBint pthread_tryjoin_np(pthread_t \fP\fIthread\fP\fB, void **\fP\fIretval\fP\fB);\fP .PP \fBint pthread_timedjoin_np(pthread_t \fP\fIthread\fP\fB, void **\fP\fIretval\fP\fB,\fP \fB const struct timespec *\fP\fIabstime\fP\fB);\fP .fi .PP \fI\-pthread\fP を付けてコンパイルとリンクを行う。 .SH 説明 これらの関数は \fBpthread_join\fP(3) と同じように動作するが、 このページで説明する違いがある。 .PP \fBpthread_tryjoin_np\fP() 関数は、スレッド \fIthread\fP の非停止 (nonblocking) での join を実行し、スレッドの終了ステータスを \fI*retval\fP に入れて返す。\fIthread\fP がまだ終了していない場合は、 \fBpthread_join\fP(3) のように停止 (block) せずに、エラーを返す。 .PP The \fBpthread_timedjoin_np\fP() function performs a join\-with\-timeout. If \fIthread\fP has not yet terminated, then the call blocks until a maximum time, specified in \fIabstime\fP, measured against the \fBCLOCK_REALTIME\fP clock. If the timeout expires before \fIthread\fP terminates, the call returns an error. The \fIabstime\fP argument is a structure of the following form, specifying an absolute time measured since the Epoch (see \fBtime\fP(2)): .PP .in +4n .EX struct timespec { time_t tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */ }; .EE .in .SH 返り値 成功すると、これらの関数は 0 を返す。 エラーの場合、エラー番号を返す。 .SH エラー これらの関数は \fBpthread_join\fP(3) と同じエラーで失敗する。 \fBpthread_tryjoin_np\fP() はさらに以下のエラーで失敗する場合がある。 .TP \fBEBUSY\fP 呼び出しを行った時点では \fIthread\fP はまだ終了していない。 .PP \fBpthread_timedjoin_np\fP() はさらに以下のエラーで失敗する場合がある。 .TP \fBETIMEDOUT\fP \fIthread\fP が終了する前に呼び出しがタイムアウトとなった。 .TP \fBEINVAL\fP \fIabstime\fP の値が無効である (\fItv_sec\fP が 0 より小さいか、 \fItv_nsec\fP 1e9 がより大きい)。 .PP \fBpthread_timedjoin_np\fP() がエラー \fBEINTR\fP を返すことはない。 .SH バージョン これらの関数は glibc バージョン 2.3.3 で初めて登場した。 .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .ad l .TS allbox; lbw22 lb lb l l l. インターフェース 属性 値 T{ \fBpthread_tryjoin_np\fP(), \fBpthread_timedjoin_np\fP() T} Thread safety MT\-Safe .TE .ad .SH 準拠 これらの関数は非標準の GNU による拡張である。 そのため、名前に "_np" (nonportable; 移植性がない) という接尾辞が 付いている。 .SH 例 以下のコードは、最大 5 秒まで join を待つ。 .PP .in +4n .EX struct timespec ts; int s; \&... if (clock_gettime(CLOCK_REALTIME, &ts) == \-1) { /* Handle error */ } ts.tv_sec += 5; s = pthread_timedjoin_np(thread, NULL, &ts); if (s != 0) { /* Handle error */ } .EE .in .SH バグ The \fBpthread_timedjoin_np\fP() function measures time by internally calculating a relative sleep interval that is then measured against the \fBCLOCK_MONOTONIC\fP clock instead of the \fBCLOCK_REALTIME\fP clock. Consequently, the timeout is unaffected by discontinuous changes to the \fBCLOCK_REALTIME\fP clock. .SH 関連項目 \fBclock_gettime\fP(2), \fBpthread_exit\fP(3), \fBpthread_join\fP(3), \fBpthreads\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。