#include <time.h>
|
|
int
nanosleep (const struct timespec *rqtp, struct timespec *rmtp); |
If rmtp is non- NULL, the timespec structure it references is updated to contain the unslept amount (the request time minus the time actually slept).
/**
* Detailed description: Sample usage of nanosleep system call.
**/
#include <stdio.h>
#include <time.h>
int main()
{
struct timespec tim, tim2;
tim.tv_sec = 1;
tim.tv_nsec = 500;
if(nanosleep(&tim , &tim2) < 0 ) {
printf("Nano sleep system call failed \n");
return -1;
}
printf("Nano sleep successfull \n");
return 0;
}
Output
Nano sleep successfull
| [EFAULT] | |
| Either rqtp or rmtp points to memory that is not a valid part of the process address space. | |
| [EINTR] | |
| The nanosleep system call was interrupted by the delivery of a signal(Not supported). | |
| [EINVAL] | |
| The rqtp argument specified a nanosecond value less than zero or greater than or equal to 1000 million. | |
| [ENOSYS] | |
| The nanosleep system call is not supported by this implementation. | |
|
© 2005-2007 Nokia |