usleep

Section: C Library Functions (3)
Updated: 2026-02-08
Index JM Home Page roff page
 

名前

usleep - マイクロ秒単位で実行を延期する  

ライブラリ

標準 C ライブラリ (libc,~-lc)  

書式

#include <unistd.h>

int usleep(useconds_t usec);

glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):

usleep():


    Since glibc 2.12:
        (_XOPEN_SOURCE >= 500) && ! (_POSIX_C_SOURCE >= 200809L)
            || /* glibc >= 2.19: */ _DEFAULT_SOURCE
            || /* glibc <= 2.19: */ _BSD_SOURCE
    Before glibc 2.12:
        _BSD_SOURCE || _XOPEN_SOURCE >= 500
 

説明

The usleep() function suspends execution of the calling thread for (at least) usec microseconds. The sleep may be lengthened slightly by any system activity or by the time spent processing the call or by the granularity of system timers.  

返り値

The usleep() function returns 0 on success. On error, -1 is returned, with errno set to indicate the error.  

エラー

EINTR
シグナルによって中断された。 signal(7) 参照。
EINVAL
usec is greater than or equal to 1000000. (On systems where that is considered an error.)
 

属性

この節で使用されている用語の説明については、 attributes(7) を参照。
インターフェース属性値

 usleep()
Thread safetyMT-Safe
 

標準規格

なし。  

歴史

4.3BSD, POSIX.1-2001. POSIX.1-2001 declares it obsolete, suggesting nanosleep(2) instead. Removed in POSIX.1-2008.

On the original BSD implementation, and before glibc 2.2.2, the return type of this function is void. The POSIX version returns int, and this is also the prototype used since glibc 2.2.2.

エラーとして EINVAL を返すというのは SUSv2 と POSIX.1-2001 でのみ文書化されている。  

警告

この関数と、 SIGALRM シグナルあるいは alarm(2), sleep(3), nanosleep(2), setitimer(2), timer_create(2), timer_delete(2), timer_getoverrun(2), timer_gettime(2), timer_settime(2), ualarm(3) といったその他のタイマー関数を同時に使った場合の動作は未定義である。  

関連項目

alarm(2), getitimer(2), nanosleep(2), select(2), setitimer(2), sleep(3), ualarm(3), useconds_t(3type), time(7)


 

Index

名前
ライブラリ
書式
説明
返り値
エラー
属性
標準規格
歴史
警告
関連項目

This document was created by man2html, using the manual pages.