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; }