From: Oleg Nesterov <oleg@tv-sign.ru>
To: akpm@osdl.org
Cc: orenl@cs.columbia.edu, roland@redhat.com,
Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org
Subject: [PATCH ? 2/2] setpgid: should work for sub-threads
Date: Sun, 11 Dec 2005 20:22:39 +0300 [thread overview]
Message-ID: <439C605F.BA7C1D5B@tv-sign.ru> (raw)
In-Reply-To: <200512110523.jBB5NVEr002551@shell0.pdx.osdl.net>
setpgid(0, pgid) or setpgid(forked_child_pid, pgid) does not work
unless the calling process is a thread_group_leader().
'man setpgid' does not tell anything about that, so I consider
this behaviour is a bug.
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
--- 2.6.15-rc5/kernel/sys.c~ 2005-12-11 22:40:33.000000000 +0300
+++ 2.6.15-rc5/kernel/sys.c 2005-12-11 22:50:39.000000000 +0300
@@ -1083,10 +1083,11 @@ asmlinkage long sys_times(struct tms __u
asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
{
struct task_struct *p;
+ struct task_struct *group_leader = current->group_leader;
int err = -EINVAL;
if (!pid)
- pid = current->pid;
+ pid = group_leader->pid;
if (!pgid)
pgid = pid;
if (pgid < 0)
@@ -1106,16 +1107,16 @@ asmlinkage long sys_setpgid(pid_t pid, p
if (!thread_group_leader(p))
goto out;
- if (p->real_parent == current) {
+ if (p->real_parent == group_leader) {
err = -EPERM;
- if (p->signal->session != current->signal->session)
+ if (p->signal->session != group_leader->signal->session)
goto out;
err = -EACCES;
if (p->did_exec)
goto out;
} else {
err = -ESRCH;
- if (p != current)
+ if (p != group_leader)
goto out;
}
@@ -1127,7 +1128,7 @@ asmlinkage long sys_setpgid(pid_t pid, p
struct task_struct *p;
do_each_task_pid(pgid, PIDTYPE_PGID, p) {
- if (p->signal->session == current->signal->session)
+ if (p->signal->session == group_leader->signal->session)
goto ok_pgid;
} while_each_task_pid(pgid, PIDTYPE_PGID, p);
goto out;
next prev parent reply other threads:[~2005-12-11 16:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200512110523.jBB5NVEr002551@shell0.pdx.osdl.net>
2005-12-11 17:22 ` [PATCH ? 1/2] setpgid: should not accept ptraced childs Oleg Nesterov
2005-12-11 17:22 ` Oleg Nesterov [this message]
2005-12-11 21:14 ` [PATCH ? 2/2] setpgid: should work for sub-threads Oren Laadan
2005-12-12 13:18 ` 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=439C605F.BA7C1D5B@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=orenl@cs.columbia.edu \
--cc=roland@redhat.com \
/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®