Name

usleep - suspend execution for microsecond intervals

Library

libc.lib

Synopsis

  #include <unistd.h>
  int usleep (useconds_t microseconds);

Return values

The usleep function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

Detailed description

The usleep function suspends execution of the calling process until either microseconds microseconds have elapsed or a signal is delivered to the process and its action is to invoke a signal-catching function or to terminate the process. System activity may lengthen the sleep by an indeterminate amount.

This function is implemented using nanosleep by pausing for microseconds microseconds or until a signal occurs. Consequently, in this implementation, sleeping has no effect on the state of process timers, and there is no special handling for SIGALRM.


Examples

#include<unistd.h>
#include<stdio.h>
 
int main()
{
 unsigned long t = 2; 
 int i;
  
 i = usleep(t);
 printf("Expected: 0 usleep returned: %d", i);
  
 return 0;
}


Output

Expected: 0 usleep returned: 0


Errors

The usleep function will fail if:
[EINTR]
  A signal was delivered to the process and its action was to invoke a signal-catching function.

Limitations

The signal related functionaities aren’t applicable to the symbian implementation as there is no support for signals from symbian.

See also

nanosleep, sleep

Feedback

For additional information or queries on this page send feedback

© 2008 Nokia Corporation. All rights reserved. This documentation can be used in the connection with this Product to help and support the user.

Top