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