mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] wait4: fill rusage on x32
@ 2023-03-06  8:59 Alexey Izbyshev
  2023-04-11 13:23 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Izbyshev @ 2023-03-06  8:59 UTC (permalink / raw)
  To: musl

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/linux/wait4.c b/src/linux/wait4.c
index 83650e34..ff2e3e66 100644
--- a/src/linux/wait4.c
+++ b/src/linux/wait4.c
@@ -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)
-- 
2.39.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [musl] [PATCH] wait4: fill rusage on x32
  2023-03-06  8:59 [musl] [PATCH] wait4: fill rusage on x32 Alexey Izbyshev
@ 2023-04-11 13:23 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2023-04-11 13:23 UTC (permalink / raw)
  To: musl

On Mon, Mar 06, 2023 at 11:59:21AM +0300, Alexey Izbyshev wrote:
> 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 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/linux/wait4.c b/src/linux/wait4.c
> index 83650e34..ff2e3e66 100644
> --- a/src/linux/wait4.c
> +++ b/src/linux/wait4.c
> @@ -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)
> -- 
> 2.39.1

Sorry this got overlooked. Applying now.

Rich

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-11 13:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-06  8:59 [musl] [PATCH] wait4: fill rusage on x32 Alexey Izbyshev
2023-04-11 13:23 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).