.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" %%%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 .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu) .\" Modified 2001-04-01 by aeb .\" Modified 2003-07-23 by aeb .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 YOSHINO Takashi .\" all rights reserved. .\" Translated Mon Jan 20 18:47:50 JST 1997 .\" by YOSHINO Takashi .\" Updated Sat May 19 JST 2001 by Kentaro Shirakata .\" Updated Mon Sep 1 JST 2003 by Kentaro Shirakata .\" Updated 2007-05-04, Akihiro MOTOKI , LDP v2.44 .\" Updated 2013-07-22, Akihiro MOTOKI .\" .TH USLEEP 3 2017\-09\-15 "" "Linux Programmer's Manual" .SH 名前 usleep \- マイクロ秒単位で実行を延期する .SH 書式 .nf \fB#include \fP .PP \fBint usleep(useconds_t \fP\fIusec\fP\fB);\fP .fi .PP .RS -4 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .RE .PP \fBusleep\fP(): .ad l .RS 4 .PD 0 .TP 4 glibc 2.12 以降: .nf (_XOPEN_SOURCE\ >=\ 500) && ! (_POSIX_C_SOURCE\ >=\ 200809L) || /* Glibc 2.19 以降: */ _DEFAULT_SOURCE || /* Glibc 2.19 以前: */ _BSD_SOURCE .fi .TP 4 glibc 2.12 より前: .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 .PD .RE .ad b .SH 説明 \fBusleep\fP() 関数は (少なくとも) \fIusec\fPマイクロ秒の間、 呼び出し元スレッドの実行を延期する。 システムの動作状況や呼び出しによる時間の消費やシステムタイマーの粒度によって、 停止時間は設定した値よりも少し延ばされるかもしれない。 .SH 返り値 \fBusleep\fP() 関数は成功すると 0 を返す。 エラーの場合、 \-1 が返され、 \fIerrno\fP にエラーの原因を示す値が設定される。 .SH エラー .TP \fBEINTR\fP シグナルによって中断された。 \fBsignal\fP(7) 参照。 .TP \fBEINVAL\fP \fIusec\fP が 1000000 以上だった。 (これをエラーとみなすシステムのみ) .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lb lb lb l l l. インターフェース 属性 値 T{ \fBusleep\fP() T} Thread safety MT\-Safe .TE .SH 準拠 4.3BSD, POSIX.1\-2001. POSIX.1\-2001 では、この関数は過去のものと宣言されている。 代わりに \fBnanosleep\fP(2) を使うこと。 POSIX.1\-2008 では、 \fBusleep\fP() の規定が削除されている。 .PP もともとの BSD の実装や、バージョン 2.2.2 より前の glibc では、 この関数の返り値の型は \fIvoid\fP である。 POSIX 版は \fIint\fP を返し、このプロトタイプは glibc 2.2.2 以降で使用されている。 .PP エラーとして \fBEINVAL\fP を返すというのは SUSv2 と POSIX.1\-2001 でのみ文書化されている。 .SH 注意 \fIuseconds_t\fP 型は [0,1000000] の範囲の整数を扱うことができる 符号なし整数型である。 明示的にこの型を使わないことでプログラムの移植性がより高まる。 以下のように使うこと。 .PP .in +4n .EX #include \&... unsigned int usecs; \&... usleep(usecs); .EE .in .PP この関数と、 \fBSIGALRM\fP シグナルあるいは \fBalarm\fP(2), \fBsleep\fP(3), \fBnanosleep\fP(2), \fBsetitimer\fP(2), \fBtimer_create\fP(2), \fBtimer_delete\fP(2), \fBtimer_getoverrun\fP(2), \fBtimer_gettime\fP(2), \fBtimer_settime\fP(2), \fBualarm\fP(3) といったその他のタイマー関数を同時に使った場合の動作は未定義である。 .SH 関連項目 \fBalarm\fP(2), \fBgetitimer\fP(2), \fBnanosleep\fP(2), \fBselect\fP(2), \fBsetitimer\fP(2), \fBsleep\fP(3), \fBualarm\fP(3), \fBtime\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。