lkml.org 
[lkml]   [2004]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: possible kernel bug in signal transit.
From
Date
В Вск, 14.03.2004, в 03:18, Andrew Morton пишет:
> Alex Lyashkov <shadow@psoft.net> wrote:
> >
> > Hello All
> >
> > I analyze kernel vanila 2.6.4 and found one possible bug in
> > __kill_pg_info function.
> >
> > for_each_task_pid(pgrp, PIDTYPE_PGID, p, l, pid) {
> > err = group_send_sig_info(sig, info, p);
> > if (retval)
> > retval = err;
> > }
> > but I think if (retval) is incorrect check. possible this cycle must be
> > for_each_task_pid(pgrp, PIDTYPE_PGID, p, l, pid) {
> > err = group_send_sig_info(sig, info, p);
> > if (ret) {
> > retval = err;
> > break;
> > }
> > }
> > because in original variant me assign to retval only first value from
> > ret and other be ignored if this value be 0.
> >
>
> No, the code's OK, albeit undesirably obscure. It will return -ESRCH if
> none of the tasks had a matching pgrp and will return the result of the
> final non-zero-returning group_send_sig_info() if one or more of the
> group_send_sig_info() calls failed, and will return zero if all of the
> group_send_sig_info() calls returned zero.
>
> Thanks for checking though..
No. it can`t return final non-zero-returning group_send_sig_info() if
first call group_send_sig_info return 0.
Example me have 3 groups it will return
1 - zero
2 - nonzero (example -1)
3 - nonzero (example -2)
original code will return zero.
but you say it will return last non zero - "-2" in example.
(do only first assignment after it retval is zero and no assignments
does.)
For her logic me can write.
=====
int retval = 0;
int err = -1;
for_each_task_pid(pgrp, PIDTYPE_PGID, p, l, pid) {
err = group_send_sig_info(sig, info, p);
if( err )
retval = err;

}
return err==-1 ? -ESRCH : retval;
===
If me not enter to this cycle - retval = -ESRCH, and last non zero err
if cycle is worked or zero if all group_send_sig_info() return zero.


--
Alex Lyashkov <shadow@psoft.net>
PSoft
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:01    [W:0.048 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site