Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ sleep(3) — UNIX 2.11BSD

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

select(2)

SLEEP(3)  —  Unix Programmer’s Manual

NAME

sleep, usleep − suspend process execution

SYNOPSIS

#include <unistd.h>

unsigned int
sleep(seconds)
      unsigned int seconds;
void
usleep(microseconds)
       long microseconds;

DESCRIPTION

The sleep function suspends execution of the calling process for seconds of clock time, or until interrupted by a signal. 

The usleep function suspends execution of the calling process for microseconds of clock time, or until interrupted by a signal. 

System activity may lengthen the suspension. 

RETURN VALUES

The sleep function returns 0, or if interrupted before seconds, the amount not slept (the requested time minus the time actually slept) in seconds.  The usleep function does not return anything (meaningful). 

SEE ALSO

select(2)

COMPATIBILITY

Previous implementations of sleep and usleep re-suspended the process if interrupted by a signal.  This implementation has been changed to return in that case, to conform to POSIX 1003.1-88. 

On the PDP-11 the previous version of usleep took a u_int as the input parameter.  This has been changed to be long so that usleep can be used for more than 65 milliseconds (a u_int could only count 65535 microseconds) of sleep.  Thus it is now possible for usleep to handle longer sleep durations than sleep. 

BUGS

On the PDP-11 the clock resolution is limited to the line frequency (usually 60Hz in the U.S.A. and 50Hz elsewhere). 

HISTORY

A usleep function appeared in 4.3BSD.  A sleep function appeared in V7. 

3rd Berkeley Distribution  —  September 26,1997

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026