Re: [PATCH] signal: Fix the error return of kill -1
From: Oleg Nesterov
Date: Wed Aug 16 2023 - 17:08:58 EST
On 08/16, Eric W. Biederman wrote:
>
> Oleg Nesterov <oleg@xxxxxxxxxx> writes:
>
> > On 08/15, David Laight wrote:
> >>
> >> or maybe even:
> >> } else {
> >> struct task_struct * p;
> >> int err;
> >> ret = -ESRCH;
> >>
> >> for_each_process(p) {
> >> if (task_pid_vnr(p) > 1 &&
> >> !same_thread_group(p, current)) {
> >> err = group_send_sig_info(sig, info, p,
> >> PIDTYPE_MAX);
> >> if (ret)
> >> ret = err;
> >
> > Hmm, indeed ;)
> >
> > and "err" can be declared inside the loop.
>
> We can't remove the success case, from my posted patch.
>
> A signal is considered as successfully delivered if at least
> one process receives it.
Yes.
Initially ret = -ESRCH.
Once group_send_sig_info() succeeds at least once (returns zero)
ret becomes 0.
After that
if (ret)
ret = err;
has no effect.
So if a signal is successfully delivered at least once the code
above returns zero.
Oleg.