1sleep(3)                   Library Functions Manual                   sleep(3)
2
3
4

NAME

6       sleep - sleep for a specified number of seconds
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <unistd.h>
13
14       unsigned int sleep(unsigned int seconds);
15

DESCRIPTION

17       sleep()  causes  the calling thread to sleep either until the number of
18       real-time seconds specified in seconds have elapsed or until  a  signal
19       arrives which is not ignored.
20

RETURN VALUE

22       Zero  if  the requested time has elapsed, or the number of seconds left
23       to sleep, if the call was interrupted by a signal handler.
24

ATTRIBUTES

26       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
27       tributes(7).
28
29       ┌────────────────────────┬───────────────┬─────────────────────────────┐
30Interface               Attribute     Value                       
31       ├────────────────────────┼───────────────┼─────────────────────────────┤
32sleep()                 │ Thread safety │ MT-Unsafe sig:SIGCHLD/linux │
33       └────────────────────────┴───────────────┴─────────────────────────────┘
34

VERSIONS

36       On   Linux,   sleep()   is   implemented  via  nanosleep(2).   See  the
37       nanosleep(2) man page for a discussion of the clock used.
38
39       On some systems, sleep() may be implemented using alarm(2) and  SIGALRM
40       (POSIX.1  permits  this); mixing calls to alarm(2) and sleep() is a bad
41       idea.
42

STANDARDS

44       POSIX.1-2008.
45

HISTORY

47       POSIX.1-2001.
48

CAVEATS

50       Using longjmp(3) from a signal handler or  modifying  the  handling  of
51       SIGALRM while sleeping will cause undefined results.
52

SEE ALSO

54       sleep(1), alarm(2), nanosleep(2), signal(2), signal(7)
55
56
57
58Linux man-pages 6.05              2023-07-20                          sleep(3)
Impressum