wait4: fix missing rusage on x32 due to wrong success condition
authorAlexey Izbyshev <izbyshev@ispras.ru>
Mon, 6 Mar 2023 08:59:21 +0000 (11:59 +0300)
committerRich Felker <dalias@aerifal.cx>
Tue, 11 Apr 2023 13:23:44 +0000 (09:23 -0400)
Resource usage data is filled by the kernel only when wait4 returns
a pid, i.e. a positive value.

Commit 5850546e9669f793aab61dfc7c4f2c1ff35c4b29 introduced this bug,
possibly because of copy-pasting from getrusage.

src/linux/wait4.c

index 83650e3..ff2e3e6 100644 (file)
@@ -12,7 +12,7 @@ pid_t wait4(pid_t pid, int *status, int options, struct rusage *ru)
        if (ru) {
                long long kru64[18];
                r = __syscall(SYS_wait4_time64, pid, status, options, kru64);
-               if (!r) {
+               if (r > 0) {
                        ru->ru_utime = (struct timeval)
                                { .tv_sec = kru64[0], .tv_usec = kru64[1] };
                        ru->ru_stime = (struct timeval)