From: Christoph Hellwig <hch@infradead.org>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Andrew Morton <akpm@osdl.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] kill_something_info: misc cleanups
Date: Sun, 17 Dec 2006 10:18:56 +0000 [thread overview]
Message-ID: <20061217101856.GA1285@infradead.org> (raw)
In-Reply-To: <20061216200510.GA5535@tv-sign.ru>
On Sat, Dec 16, 2006 at 11:05:10PM +0300, Oleg Nesterov wrote:
> static int kill_something_info(int sig, struct siginfo *info, int pid)
> {
> int ret;
> +
> + rcu_read_lock();
> + if (pid > 0) {
> + ret = kill_pid_info(sig, info, find_pid(pid));
> + } else if (pid == -1) {
> + struct task_struct *p;
> + int found = 0;
> +
> + ret = 0;
> + read_lock(&tasklist_lock);
> + for_each_process(p)
> + if (!is_init(p) && p != current->group_leader) {
> + int err = group_send_sig_info(sig, info, p);
> + if (err != -EPERM)
> + ret = err;
> + found = 1;
> + }
> + read_unlock(&tasklist_lock);
> + if (!found)
> + ret = -ESRCH;
This branch should probably be factored out into a helper of it's own:
static int kill_this_group_info(int sig, struct siginfo *info)
{
struct task_struct *p;
int ret = 0, found = 0;
read_lock(&tasklist_lock);
for_each_process(p) {
if (!is_init(p) && p != current->group_leader) {
int err = group_send_sig_info(sig, info, p);
if (err != -EPERM)
ret = err;
found = 1;
}
}
read_unlock(&tasklist_lock);
if (!found)
return -ESRCH;
return found ? ret : -ESRCH;
}
> + } else {
> + struct pid *grp = task_pgrp(current);
> + if (pid != 0)
> + grp = find_pid(-pid);
> + ret = kill_pgrp_info(sig, info, grp);
> + }
This also looks rather unreadable, an
} else if (pid) {
ret = kill_pgrp_info(sig, info, find_pid(-pid));
} else {
ret = kill_pgrp_info(sig, info, task_pgrp(current));
}
might be slightly more code, but also a lot more readable.
next prev parent reply other threads:[~2006-12-17 10:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-16 20:05 Oleg Nesterov
2006-12-16 23:10 ` Eric W. Biederman
2006-12-17 0:37 ` Oleg Nesterov
2006-12-17 1:09 ` Eric W. Biederman
2006-12-17 10:18 ` Christoph Hellwig [this message]
2006-12-17 11:22 ` Eric W. Biederman
2006-12-17 14:40 ` Oleg Nesterov
2006-12-18 13:09 ` Eric W. Biederman
2006-12-18 21:24 ` Oleg Nesterov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061217101856.GA1285@infradead.org \
--to=hch@infradead.org \
--cc=akpm@osdl.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@tv-sign.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®