lkml.org 
[lkml]   [2004]   [Mar]   [14]   [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, в 07:47, Andrew Morton пишет:
> Alex Lyashkov <shadow@psoft.net> wrote:
> >
> > > int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp)
> > > {
> > > struct task_struct *p;
> > > struct list_head *l;
> > > struct pid *pid;
> > > int retval;
> > > int found;
> > >
> > > if (pgrp <= 0)
> > > return -EINVAL;
> > >
> > > found = 0;
> > > retval = 0;
> > > for_each_task_pid(pgrp, PIDTYPE_PGID, p, l, pid) {
> > > int err;
> > >
> > > found = 1;
> > > err = group_send_sig_info(sig, info, p);
> > > if (!retval)
> > > retval = err;
> > > }
> > > return found ? retval : -ESRCH;
> > > }
> > not. it error. At this code you save first non zero value err but other
> > been ignored.
>
> Well we can only return one error code. Or are you suggesting that we
> should terminate the loop early on error? If so, why?
You say me can return _last_ error core. but this function return
_first_.

I write second variant where not terminate loop and save _last_ error
code (i was sending in previous mail). but if you have i write full
function:
====
int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp)
{
struct task_struct *p;
struct list_head *l;
struct pid *pid;
int retval = 0;
int err = -1;
if (pgrp <= 0)
return -EINVAL;
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;
}
===
what you think about its code ?

--
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    [from the cache]
©2003-2011 Jasper Spaans