'\" te .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved. .\" Copyright (c) 1980 Regents of the University of California. All rights reserved. The Berkeley software License Agreement specifies the terms and conditions for redistribution. .TH SLEEP 3UCB "Oct 30, 2007" .SH NAME sleep \- suspend execution for interval .SH SYNOPSIS .LP .nf \fB/usr/ucb/cc\fR [ \fIflag\fR ... ] \fIfile\fR ... \fBint\fR \fBsleep\fR(\fIseconds\fR) \fBunsigned\fR \fIseconds\fR; .fi .SH DESCRIPTION .sp .LP \fBsleep()\fR suspends the current process from execution for the number of seconds specified by the argument. The actual suspension time may be up to 1 second less than that requested, because scheduled wakeups occur at fixed 1-second intervals, and may be an arbitrary amount longer because of other activity in the system. .sp .LP \fBsleep()\fR is implemented by setting an interval timer and pausing until it expires. The previous state of this timer is saved and restored. If the sleep time exceeds the time to the expiration of the previous value of the timer, the process sleeps only until the timer would have expired, and the signal which occurs with the expiration of the timer is sent one second later. .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ MT-Level Async-Signal-Safe .TE .SH SEE ALSO .sp .LP \fBalarm\fR(2), \fBgetitimer\fR(2), \fBlongjmp\fR(3C), \fBsiglongjmp\fR(3C), \fBsleep\fR(3C), \fBusleep\fR(3C), \fBattributes\fR(5) .SH NOTES .sp .LP Use of these interfaces should be restricted to only applications written on BSD platforms. Use of these interfaces with any of the system libraries or in multi-thread applications is unsupported. .sp .LP \fBSIGALRM\fR should \fInot\fR be blocked or ignored during a call to \fBsleep()\fR. Only a prior call to \fBalarm\fR(2) should generate \fBSIGALRM\fR for the calling process during a call to \fBsleep()\fR. A signal-catching function should \fInot\fR interrupt a call to \fBsleep()\fR to call \fBsiglongjmp\fR(3C) or \fBlongjmp\fR(3C) to restore an environment saved prior to the \fBsleep()\fR call. .SH WARNINGS .sp .LP \fBsleep()\fR is slightly incompatible with \fBalarm\fR(2). Programs that do not execute for at least one second of clock time between successive calls to \fBsleep()\fR indefinitely delay the alarm signal. Use \fBsleep\fR(3C). Each \fBsleep\fR(3C) call postpones the alarm signal that would have been sent during the requested sleep period to occur one second later.