]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/sleep.3
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man3 / sleep.3
1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .\" Modified Sat Jul 24 18:16:02 1993 by Rik Faith (faith@cs.unc.edu)
6 .TH sleep 3 (date) "Linux man-pages (unreleased)"
7 .SH NAME
8 sleep \- sleep for a specified number of seconds
9 .SH LIBRARY
10 Standard C library
11 .RI ( libc ", " \-lc )
12 .SH SYNOPSIS
13 .nf
14 .B #include <unistd.h>
15 .PP
16 .BI "unsigned int sleep(unsigned int " "seconds" );
17 .fi
18 .SH DESCRIPTION
19 .BR sleep ()
20 causes the calling thread to sleep either until
21 the number of real-time seconds specified in
22 .I seconds
23 have elapsed or until a signal arrives which is not ignored.
24 .SH RETURN VALUE
25 Zero if the requested time has elapsed,
26 or the number of seconds left to sleep,
27 if the call was interrupted by a signal handler.
28 .SH ATTRIBUTES
29 For an explanation of the terms used in this section, see
30 .BR attributes (7).
31 .ad l
32 .nh
33 .TS
34 allbox;
35 lbx lb lb
36 l l l.
37 Interface Attribute Value
38 T{
39 .BR sleep ()
40 T} Thread safety MT-Unsafe sig:SIGCHLD/linux
41 .TE
42 .hy
43 .ad
44 .sp 1
45 .SH STANDARDS
46 POSIX.1-2001, POSIX.1-2008.
47 .SH NOTES
48 On Linux,
49 .BR sleep ()
50 is implemented via
51 .BR nanosleep (2).
52 See the
53 .BR nanosleep (2)
54 man page for a discussion of the clock used.
55 .SS Portability notes
56 On some systems,
57 .BR sleep ()
58 may be implemented using
59 .BR alarm (2)
60 and
61 .B SIGALRM
62 (POSIX.1 permits this);
63 mixing calls to
64 .BR alarm (2)
65 and
66 .BR sleep ()
67 is a bad idea.
68 .PP
69 Using
70 .BR longjmp (3)
71 from a signal handler or modifying the handling of
72 .B SIGALRM
73 while sleeping will cause undefined results.
74 .SH SEE ALSO
75 .BR sleep (1),
76 .BR alarm (2),
77 .BR nanosleep (2),
78 .BR signal (2),
79 .BR signal (7)