blob: 1171a0a6c7e08130b195a011ff99ebec94cd62b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
int main() {
time_t start;
time_t taken;
start = time(0);
printf("sleep(2) ret: %d\n", sleep(2));
taken = time(0) - start;
printf("after sleep(2) between 2 and 3: %d\n", taken >= 2 && taken <= 3);
printf("errno: %d\n", errno);
errno = 0;
start = time(0);
printf("usleep(3000000) ret: %d\n", usleep(3000000));
taken = time(0) - start;
printf("after usleep(3000000) between 3 and 4: %d\n", taken >= 3 && taken <= 4);
printf("errno: %d\n", errno);
return 0;
}
|