[LTP] [PATCH 1/1] syscalls: Add missing WEXITSTATUS() check

Cyril Hrubis chrubis@suse.cz
Tue Nov 12 13:17:25 CET 2024


Hi!
> > > -	if (WIFEXITED(status))
> > > +	if (WIFEXITED(status) && !WEXITSTATUS(status))
> > >  		return 0;
> 
> > >  	tst_res(TCONF, "No coredump produced after signal (%d)",
> 
> > This one is not complete. We do exit(1) if madvise fails that would be
> > previously caught here so we have to add:
> 
> > diff --git a/testcases/kernel/syscalls/madvise/madvise08.c b/testcases/kernel/syscalls/madvise/madvise08.c
> > index 96bcaf159..f8f74ef4f 100644
> > --- a/testcases/kernel/syscalls/madvise/madvise08.c
> > +++ b/testcases/kernel/syscalls/madvise/madvise08.c
> > @@ -165,7 +165,7 @@ static pid_t run_child(int advice)
> >                                 fmem,
> >                                 FMEMSIZE,
> >                                 advstr);
> > -                       exit(1);
> > +                       exit(0);
> >                 }
> >                 abort();
> >         }
> 
> Good catch, thanks!
> 
> Maybe it'd be more logical to keep exit(1) (it's error) and check against
> WEXITSTATUS(status) == 1, but it's a minor detail, let's keep exit(0).

I wouldn't do so, as it may confuse people into thinking that the return
value actually carries any information, which it does not since the
failure has been already reported. I would just stick to exit(0) which
makes it more clear that we just need to exit the process, nothing more.

> Can I merge with your RBT?

Yes, with the fix above.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list