3 #include <sys/resource.h>
8 pid_t
wait4(pid_t pid
, int *status
, int options
, struct rusage
*ru
)
11 #ifdef SYS_wait4_time64
14 r
= __syscall(SYS_wait4_time64
, pid
, status
, options
, kru64
);
16 ru
->ru_utime
= (struct timeval
)
17 { .tv_sec
= kru64
[0], .tv_usec
= kru64
[1] };
18 ru
->ru_stime
= (struct timeval
)
19 { .tv_sec
= kru64
[2], .tv_usec
= kru64
[3] };
20 char *slots
= (char *)&ru
->ru_maxrss
;
21 for (int i
=0; i
<14; i
++)
22 *(long *)(slots
+ i
*sizeof(long)) = kru64
[4+i
];
24 if (SYS_wait4_time64
== SYS_wait4
|| r
!= -ENOSYS
)
25 return __syscall_ret(r
);
28 char *dest
= ru
? (char *)&ru
->ru_maxrss
- 4*sizeof(long) : 0;
29 r
= __syscall(SYS_wait4
, pid
, status
, options
, dest
);
30 if (r
>0 && ru
&& sizeof(time_t) > sizeof(long)) {
32 memcpy(kru
, dest
, 4*sizeof(long));
33 ru
->ru_utime
= (struct timeval
)
34 { .tv_sec
= kru
[0], .tv_usec
= kru
[1] };
35 ru
->ru_stime
= (struct timeval
)
36 { .tv_sec
= kru
[2], .tv_usec
= kru
[3] };
38 return __syscall_ret(r
);