[haiku-bugs] Re: [Haiku] #13546: wait4() doesn't seem to work

  • From: "pulkomandy" <trac@xxxxxxxxxxxx>
  • Date: Thu, 06 Jul 2017 13:47:37 -0000

#13546: wait4() doesn't seem to work
---------------------------------+----------------------------
   Reporter:  korli              |      Owner:  nobody
       Type:  bug                |     Status:  new
   Priority:  normal             |  Milestone:  Unscheduled
  Component:  System/libroot.so  |    Version:  R1/Development
 Resolution:                     |   Keywords:
 Blocked By:                     |   Blocking:
Has a Patch:  0                  |   Platform:  All
---------------------------------+----------------------------

Comment (by pulkomandy):

 I hit this same problem while porting boost_build.

 Investigation:

 wait4 calls waitpid. This works as expected. Then, it calls getrusage
 using the pid to get the final resource usage. However, at this point the
 team is already gone, and getrusage fails.

 Workaround:

 Do not return -1 when getrusage fails. Instead, set the rusage to some
 invalid value. But then we give bogus rusage data to apps in that
 situation, which is not good.

 Proper fix:

 It seems wait4 needs to be a syscall, so it can get usage just as the
 process terminates and before the PID becomes invalid. Alternatively,
 getrusage on a dead team should be allowed for some (?) time after its
 death.

--
Ticket URL: <https://dev.haiku-os.org/ticket/13546#comment:2>
Haiku <https://dev.haiku-os.org>
The Haiku operating system.

Other related posts: