From 7d39f1f13781614037e5376bd979642d8617500b Mon Sep 17 00:00:00 2001 From: "Bruno G. Albuquerque" Date: Thu, 19 Nov 2009 12:48:45 +0000 Subject: [PATCH] =?UTF-8?q?-=20Get=20the=20process=20information=20of=20th?= =?UTF-8?q?e=20correct=20team=20by=20using=20get=5Fteam=5Fusage=5Finfo=20?= =?UTF-8?q?=20=20instead=20of=20getrusage.=20-=20Thanks=20Fran=C3=A7ois=20?= =?UTF-8?q?for=20insisting=20on=20this.=20:)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34133 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/libs/bsd/wait.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/libs/bsd/wait.c b/src/libs/bsd/wait.c index 55f0268a1d..368d8dddad 100644 --- a/src/libs/bsd/wait.c +++ b/src/libs/bsd/wait.c @@ -6,7 +6,9 @@ * Bruno Albuquerque, bga@bug-br.org.br */ +#include +#include #include @@ -21,9 +23,20 @@ pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage) { pid_t waitPid = waitpid(pid, status, options); - if (waitPid != -1) - getrusage(RUSAGE_CHILDREN, rusage); + if (waitPid != -1) { + team_usage_info info; + + // Obtain info for the process that changed state. + if (get_team_usage_info(waitPid, RUSAGE_SELF, &info) != B_OK) + 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 waitPid; }