RE: [PATCH] signal: Fix the error return of kill -1

From: David Laight
Date: Tue Aug 15 2023 - 10:48:03 EST


From: Oleg Nesterov
> Sent: 14 August 2023 16:44
...
> Even simpler
>
> } else {
> struct task_struct * p;
> bool success = false;
> int err = -ESRCH;

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);
> success |= !err;
> }
> }
> ret = success ? 0 : err;
> }

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;
}
}
}

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)