From: Linus Torvalds <torvalds@osdl.org>
To: Michael Kerrisk <michael.kerrisk@gmx.net>
Cc: Andrew Morton <akpm@osdl.org>,
Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2.6.7] kill(2), killpg(2) wrongly fail with EPERM
Date: Wed, 16 Jun 2004 09:12:31 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.58.0406160910020.27252@ppc970.osdl.org> (raw)
In-Reply-To: <40D07A1A.6828.1C33C7E@localhost>
On Wed, 16 Jun 2004, Michael Kerrisk wrote:
>
> The following patch for 2.6.7 fixes the problem. Please apply.
How about this imho nicer version instead? It results in the main loop
being just:
success = 0;
retval = -ESRCH;
for_each_task_pid(pgrp, PIDTYPE_PGID, p, l, pid) {
int err = group_send_sig_info(sig, info, p);
success |= !err;
retval = err;
}
return success ? 0 : retval;
which seems sensible. If _any_ group-send succeeded, we want to return
success (ie this is not a EPERM vs everything else issue).
Does this work for you?
Linus
-----
===== kernel/signal.c 1.120 vs edited =====
--- 1.120/kernel/signal.c Wed Jun 9 01:46:51 2004
+++ edited/kernel/signal.c Wed Jun 16 09:09:51 2004
@@ -1071,23 +1071,19 @@
struct task_struct *p;
struct list_head *l;
struct pid *pid;
- int retval;
- int found;
+ int retval, success;
if (pgrp <= 0)
return -EINVAL;
- found = 0;
- retval = 0;
+ success = 0;
+ retval = -ESRCH;
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;
+ int err = group_send_sig_info(sig, info, p);
+ success |= !err;
+ retval = err;
}
- return found ? retval : -ESRCH;
+ return success ? 0 : retval;
}
int
next parent reply other threads:[~2004-06-16 16:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <40D07A1A.6828.1C33C7E@localhost>
2004-06-16 16:12 ` Linus Torvalds [this message]
2004-06-16 18:07 ` Michael Kerrisk
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=Pine.LNX.4.58.0406160910020.27252@ppc970.osdl.org \
--to=torvalds@osdl.org \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.kerrisk@gmx.net \
/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®