blob: 3dc5d2105e8c7307bf41bce6b5c2bde0b0ae6d08 (
plain) (
blame)
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
|
#include "cmd_rusage.h"
void *cmd_rusage(void *data)
{
char *ret = NULL;
int fret=-1;
const int buf_size = 128;
char buf[buf_size+1];
struct rusage cur_proc_rusage;
printf("RUSAGE\n");
fret = getrusage(RUSAGE_SELF, &cur_proc_rusage);
if (fret<0)
{
ret = alloc_new_str("Cant get rusage mate\n");
}
printf("USER %ld SYS %ld\n",
cur_proc_rusage.ru_utime.tv_sec,
cur_proc_rusage.ru_stime.tv_sec
);
snprintf(buf, buf_size, "USER %ld SYS %ld\n",
cur_proc_rusage.ru_utime.tv_sec,
cur_proc_rusage.ru_stime.tv_sec
);
ret = alloc_new_str(buf);
return ret;
}
|