[haiku-commits] r34133 - haiku/trunk/src/libs/bsd

  • From: bga@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 19 Nov 2009 13:48:45 +0100 (CET)

Author: bga
Date: 2009-11-19 13:48:45 +0100 (Thu, 19 Nov 2009)
New Revision: 34133
Changeset: http://dev.haiku-os.org/changeset/34133/haiku

Modified:
   haiku/trunk/src/libs/bsd/wait.c
Log:
- Get the process information of the correct team by using get_team_usage_info
  instead of getrusage.
- Thanks Fran?\195?\167ois for insisting on this. :)



Modified: haiku/trunk/src/libs/bsd/wait.c
===================================================================
--- haiku/trunk/src/libs/bsd/wait.c     2009-11-19 12:27:25 UTC (rev 34132)
+++ haiku/trunk/src/libs/bsd/wait.c     2009-11-19 12:48:45 UTC (rev 34133)
@@ -6,7 +6,9 @@
  *             Bruno Albuquerque, bga@xxxxxxxxxxxxx
  */
 
+#include <OS.h>
 
+#include <sys/resource.h>
 #include <sys/wait.h>
 
 
@@ -21,9 +23,20 @@
 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;
 }
 


Other related posts:

  • » [haiku-commits] r34133 - haiku/trunk/src/libs/bsd - bga