mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 11:37:35 +00:00
Add i/o statistics to wait4() about child process
This commit is contained in:
parent
b9eb656e41
commit
58ef4e6df8
6 changed files with 39 additions and 8 deletions
|
@ -16,19 +16,17 @@
|
||||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
#include "libc/calls/calls.h"
|
|
||||||
#include "libc/calls/sig.internal.h"
|
#include "libc/calls/sig.internal.h"
|
||||||
#include "libc/calls/state.internal.h"
|
#include "libc/calls/struct/rusage.internal.h"
|
||||||
#include "libc/calls/struct/rusage.h"
|
|
||||||
#include "libc/calls/syscall_support-nt.internal.h"
|
#include "libc/calls/syscall_support-nt.internal.h"
|
||||||
#include "libc/fmt/conv.h"
|
#include "libc/fmt/conv.h"
|
||||||
#include "libc/nt/accounting.h"
|
#include "libc/nt/accounting.h"
|
||||||
#include "libc/nt/process.h"
|
#include "libc/nt/process.h"
|
||||||
#include "libc/nt/runtime.h"
|
#include "libc/nt/runtime.h"
|
||||||
|
#include "libc/nt/struct/filetime.h"
|
||||||
#include "libc/nt/struct/iocounters.h"
|
#include "libc/nt/struct/iocounters.h"
|
||||||
#include "libc/nt/struct/processmemorycounters.h"
|
#include "libc/nt/struct/processmemorycounters.h"
|
||||||
#include "libc/nt/thread.h"
|
#include "libc/nt/thread.h"
|
||||||
#include "libc/str/str.h"
|
|
||||||
#include "libc/sysv/consts/rusage.h"
|
#include "libc/sysv/consts/rusage.h"
|
||||||
#include "libc/sysv/errfuns.h"
|
#include "libc/sysv/errfuns.h"
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "libc/nt/process.h"
|
#include "libc/nt/process.h"
|
||||||
#include "libc/nt/runtime.h"
|
#include "libc/nt/runtime.h"
|
||||||
#include "libc/nt/struct/filetime.h"
|
#include "libc/nt/struct/filetime.h"
|
||||||
|
#include "libc/nt/struct/iocounters.h"
|
||||||
#include "libc/nt/struct/processentry32.h"
|
#include "libc/nt/struct/processentry32.h"
|
||||||
#include "libc/nt/struct/processmemorycounters.h"
|
#include "libc/nt/struct/processmemorycounters.h"
|
||||||
#include "libc/nt/synchronization.h"
|
#include "libc/nt/synchronization.h"
|
||||||
|
@ -68,6 +69,13 @@ static textwindows void AddProcessStats(int64_t h, struct rusage *ru) {
|
||||||
} else {
|
} else {
|
||||||
STRACE("%s failed %u", "GetProcessTimes", GetLastError());
|
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,
|
static textwindows int sys_wait4_nt_impl(int *pid, int *opt_out_wstatus,
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
#include "libc/fmt/fmt.h"
|
#include "libc/fmt/fmt.h"
|
||||||
|
#include "libc/stdio/lock.internal.h"
|
||||||
#include "libc/stdio/stdio.h"
|
#include "libc/stdio/stdio.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +39,11 @@ int fscanf(FILE *stream, const char *fmt, ...) {
|
||||||
int rc;
|
int rc;
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
rc = __vcscanf((int (*)(void *))fgetc, (void *)ungetc, stream, fmt, va);
|
flockfile(stream);
|
||||||
|
rc = __vcscanf((void *)fgetc_unlocked, //
|
||||||
|
(void *)ungetc_unlocked, //
|
||||||
|
stream, fmt, va);
|
||||||
|
funlockfile(stream);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,9 @@
|
||||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
|
#include "libc/calls/struct/fd.internal.h"
|
||||||
#include "libc/fmt/fmt.h"
|
#include "libc/fmt/fmt.h"
|
||||||
|
#include "libc/stdio/lock.internal.h"
|
||||||
#include "libc/stdio/stdio.h"
|
#include "libc/stdio/stdio.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +29,11 @@ int scanf(const char *fmt, ...) {
|
||||||
int rc;
|
int rc;
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, fmt);
|
va_start(va, fmt);
|
||||||
rc = __vcscanf((int (*)(void *))fgetc, NULL, stdin, fmt, va);
|
flockfile(stdin);
|
||||||
|
rc = __vcscanf((void *)fgetc_unlocked, //
|
||||||
|
(void *)ungetc_unlocked, //
|
||||||
|
stdin, fmt, va);
|
||||||
|
funlockfile(stdin);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
#include "libc/fmt/fmt.h"
|
#include "libc/fmt/fmt.h"
|
||||||
|
#include "libc/stdio/lock.internal.h"
|
||||||
#include "libc/stdio/stdio.h"
|
#include "libc/stdio/stdio.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,5 +25,11 @@
|
||||||
* @see libc/fmt/vcscanf.h
|
* @see libc/fmt/vcscanf.h
|
||||||
*/
|
*/
|
||||||
int vfscanf(FILE *stream, const char *fmt, va_list ap) {
|
int vfscanf(FILE *stream, const char *fmt, va_list ap) {
|
||||||
return __vcscanf((void *)fgetc, (void *)ungetc, stream, fmt, ap);
|
int rc;
|
||||||
|
flockfile(stream);
|
||||||
|
rc = __vcscanf((void *)fgetc_unlocked, //
|
||||||
|
(void *)ungetc_unlocked, //
|
||||||
|
stream, fmt, ap);
|
||||||
|
funlockfile(stream);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||||
#include "libc/fmt/fmt.h"
|
#include "libc/fmt/fmt.h"
|
||||||
|
#include "libc/stdio/lock.internal.h"
|
||||||
#include "libc/stdio/stdio.h"
|
#include "libc/stdio/stdio.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,5 +25,11 @@
|
||||||
* @see libc/fmt/vcscanf.h
|
* @see libc/fmt/vcscanf.h
|
||||||
*/
|
*/
|
||||||
int vscanf(const char *fmt, va_list ap) {
|
int vscanf(const char *fmt, va_list ap) {
|
||||||
return __vcscanf((int (*)(void *))fgetc, (void *)ungetc, stdin, fmt, ap);
|
int rc;
|
||||||
|
flockfile(stdin);
|
||||||
|
rc = __vcscanf((void *)fgetc_unlocked, //
|
||||||
|
(void *)ungetc_unlocked, //
|
||||||
|
stdin, fmt, ap);
|
||||||
|
flockfile(stdout);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue