Implemented getrusage

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10241 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2004-11-25 19:24:24 +00:00
parent 80899a91b9
commit 4693e9c7a5
+17 -6
View File
@@ -1,19 +1,30 @@
/*
** Copyright 2004, JérômDuval, [email protected].
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the Haiku License.
** Distributed under the terms of the MIT License.
*/
#include <OS.h>
#include <sys/resource.h>
#include <syscalls.h>
#include <errno.h>
int
getrusage(int who, struct rusage *rusage)
{
// ToDo: implement me!
errno = B_BAD_VALUE;
return -1;
team_usage_info info;
if (get_team_usage_info(B_CURRENT_TEAM, who, &info) != B_OK) {
errno = B_BAD_VALUE;
return -1;
}
rusage->ru_utime.tv_sec = info.user_time / 1000000;
rusage->ru_utime.tv_usec = info.user_time % 1000000;
rusage->ru_stime.tv_sec = info.kernel_time / 1000000;
rusage->ru_stime.tv_usec = info.kernel_time % 1000000;
return 0;
}