summaryrefslogtreecommitdiff
path: root/cmd_rusage.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd_rusage.c')
-rw-r--r--cmd_rusage.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/cmd_rusage.c b/cmd_rusage.c
new file mode 100644
index 0000000..3dc5d21
--- /dev/null
+++ b/cmd_rusage.c
@@ -0,0 +1,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;
+}