diff --git a/src/kernel/libroot/posix/sys/getrusage.c b/src/kernel/libroot/posix/sys/getrusage.c index 81f307cc25..a73f9a6282 100644 --- a/src/kernel/libroot/posix/sys/getrusage.c +++ b/src/kernel/libroot/posix/sys/getrusage.c @@ -1,19 +1,30 @@ /* +** Copyright 2004, JérômDuval, jerome.duval@free.fr. ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the Haiku License. +** Distributed under the terms of the MIT License. */ - +#include #include -#include #include 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; }