blob: ffc4bad49b1c1c2ba3419e6661c8811701a16a5c (
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
25
26
27
28
29
30
31
32
33
34
35
|
#include <err.h>
#include <limits.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/types.h>
int
main()
{
struct timeval utime;
struct timeval stime;
struct rusage r;
int i;
timerclear(&utime);
timerclear(&stime);
do {
if (getrusage(RUSAGE_SELF, &r) == -1)
err(1, "getrusage");
if (timercmp(&(r.ru_utime), &utime, <))
errx(1, "user time decreased");
utime = r.ru_utime;
if (timercmp(&(r.ru_stime), &stime, <))
errx(1, "system time decreased");
stime = r.ru_stime;
} while (utime.tv_sec < 1 && stime.tv_sec < 1);
return 0;
}
|