Messages in this thread | | | Date | Mon, 14 Aug 2023 16:06:52 +0200 | From | Oleg Nesterov <> | Subject | Re: [PATCH] signal: Fix the error return of kill -1 |
| |
Hi Eric,
This change LGTM, but ...
On 08/11, Eric W. Biederman wrote: > > @@ -1602,7 +1603,8 @@ static int kill_something_info(int sig, struct kernel_siginfo *info, pid_t pid) > ret = __kill_pgrp_info(sig, info, > pid ? find_vpid(-pid) : task_pgrp(current)); > } else { > - int retval = 0, count = 0; > + bool found = false, success = false; > + int retval = 0; > struct task_struct * p; > > for_each_process(p) { > @@ -1610,12 +1612,12 @@ static int kill_something_info(int sig, struct kernel_siginfo *info, pid_t pid) > !same_thread_group(p, current)) { > int err = group_send_sig_info(sig, info, p, > PIDTYPE_MAX); > - ++count; > - if (err != -EPERM) > - retval = err; > + found = true; > + success |= !err; > + retval = err; > } > } > - ret = count ? retval : -ESRCH; > + ret = success ? 0 : (found ? retval : -ESRCH);
Why do we need the "bool found" variable ? Afacis
} else { bool success = false; int retval = -ESRCH; struct task_struct * p;
for_each_process(p) { if (task_pid_vnr(p) > 1 && !same_thread_group(p, current)) { int err = group_send_sig_info(sig, info, p, PIDTYPE_MAX); success |= !err; retval = err; } } ret = success ? 0 : retval; }
does the same?
Oleg.
| |