unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (SunOS-4.1.3)
Page:
Section:
Apropos / Subsearch:
optional field

SLEEP(3V)                                                            SLEEP(3V)



NAME
       sleep - suspend execution for interval

SYNOPSIS
       int sleep(seconds)
       unsigned seconds;

SYSTEM V SYNOPSIS
       unsigned sleep(seconds)
       unsigned seconds;

DESCRIPTION
       sleep()  suspends  the current process from execution for the number of
       seconds specified by the argument.  The actual suspension time  may  be
       an arbitrary amount longer because of other activity in the system.

       sleep()  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.

SYSTEM V DESCRIPTION
       sleep() suspends the current process from execution  until  either  the
       number of real time seconds specified by seconds have elapsed or a sig-
       nal is delivered to the calling process and its action is to  invoke  a
       signal-catching  function  or to terminate the process.  The suspension
       time may be an arbitrary amount longer than requested because of  other
       activity  in  the  system.   The  value returned by sleep() will be the
       "unslept" amount (the requested time minus the time actually slept)  in
       case  the caller had an alarm set to go off earlier than the end of the
       requested sleep() time, or premature arousal due to another caught sig-
       nal.

RETURN VALUES
       sleep() returns no useful value.

SYSTEM V RETURN VALUES
       If  sleep()  returns because the requested time has elapsed, it returns
       0.  If sleep() returns due to the delivery of a signal, it returns  the
       "unslept" amount in seconds.

SEE ALSO
       getitimer(2), sigpause(2V), usleep(3)

NOTES
       SIGALRM  should  not  be  blocked  or ignored during a call to sleep().
       Only a prior call to alarm(3V) should generate SIGALRM for the  calling
       process  during  a  call to sleep().  A signal-catching function should
       not interrupt a call to sleep() to call siglongjmp()  or  longjmp()  to
       restore an environment saved prior to the sleep() call.

WARNINGS
       sleep()  is slightly incompatible with alarm(3V).  Programs that do not
       execute for at least one second of clock time between successive  calls
       to  sleep() indefinitely delay the alarm signal.  Use System V sleep().
       Each sleep(3V) call postpones the alarm signal  that  would  have  been
       sent during the requested sleep period to occur one second later.



                                21 January 1990                      SLEEP(3V)