>>-sleep--number-----------------------------------------------><
Function
sleep invokes the sleep callable service to suspend running
of the calling thread (process) until either the number of seconds
specified by number has elapsed, or a signal is delivered
to the calling thread to invoke a signal-catching function or end
the thread.
Usage notes
- The suspension can actually be longer than the requested time,
due to the scheduling of other activity by the system.
- The sleep service suspends the thread running for a specified
number of seconds, or until a signal is delivered to the calling thread
that invokes a signal-catching function or ends the thread. An unblocked
signal received during this time prematurely wakes up the thread.
The appropriate signal-handling function is invoked to handle the
signal. When that signal-handling function returns, the sleep service
returns immediately, even if there is sleep time remaining.
- The sleep service returns a zero in RETVAL if it has slept for
the number of seconds specified. If the time specified by number has
not elapsed when the sleep service is interrupted because of the delivery
of a signal, the sleep service returns the unslept amount of time
(the requested time minus the time actually slept when the signal
was delivered) in seconds. Any time consumed by signal-catching functions
is not reflected in the value returned by the sleep service.
- The following are usage notes for a SIGALRM signal
generated by the alarm or kill calls during the execution of the sleep
call:
- If the calling thread has SIGALRM blocked
prior to calling the sleep service, the sleep service does not return
when SIGALRM is generated, and the SIGALRM signal is left pending when sleep returns.
- If the calling process has SIGALRM ignored
when the SIGALRM signal is generated, then the
sleep service does not return and the SIGALRM signal
is ignored.
- If the calling process has SIGALRM set to
a signal-catching function, that function interrupts the sleep service
and receives control. The sleep service returns any unslept amount
of time, as it does for any other type of signal.
- An EC6 abend is generated when the caller's PSW key or RB state
prevents signals from being delivered.
Example
In the following example, assume that
timer was assigned
a value earlier in the exec:
"sleep (timer)"