Add i/o statistics to wait4() about child process

This commit is contained in:
Justine Tunney 2023-08-21 21:25:33 -07:00
parent b9eb656e41
commit 58ef4e6df8
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
6 changed files with 39 additions and 8 deletions

View file

@ -16,19 +16,17 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/calls.h"
#include "libc/calls/sig.internal.h"
#include "libc/calls/state.internal.h"
#include "libc/calls/struct/rusage.h"
#include "libc/calls/struct/rusage.internal.h"
#include "libc/calls/syscall_support-nt.internal.h"
#include "libc/fmt/conv.h"
#include "libc/nt/accounting.h"
#include "libc/nt/process.h"
#include "libc/nt/runtime.h"
#include "libc/nt/struct/filetime.h"
#include "libc/nt/struct/iocounters.h"
#include "libc/nt/struct/processmemorycounters.h"
#include "libc/nt/thread.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/rusage.h"
#include "libc/sysv/errfuns.h"

View file

@ -35,6 +35,7 @@
#include "libc/nt/process.h"
#include "libc/nt/runtime.h"
#include "libc/nt/struct/filetime.h"
#include "libc/nt/struct/iocounters.h"
#include "libc/nt/struct/processentry32.h"
#include "libc/nt/struct/processmemorycounters.h"
#include "libc/nt/synchronization.h"
@ -68,6 +69,13 @@ static textwindows void AddProcessStats(int64_t h, struct rusage *ru) {
} else {
STRACE("%s failed %u", "GetProcessTimes", GetLastError());
}
struct NtIoCounters iocount;
if (GetProcessIoCounters(h, &iocount)) {
ru->ru_inblock += iocount.ReadOperationCount;
ru->ru_oublock += iocount.WriteOperationCount;
} else {
STRACE("%s failed %u", "GetProcessIoCounters", GetLastError());
}
}
static textwindows int sys_wait4_nt_impl(int *pid, int *opt_out_wstatus,