lkml.org 
[lkml]   [2003]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] bug in setpgid()? process groups and thread groups
From
Date
Hi,

I think there's a bug in setpgid(). At present, it only allows the
thread group leader to change process groups, but it doesn't change the
other threads in the thread group to the new process group.

The result is that if a thread group leader changes process groups, all
the other threads are left in the old group - and they can't switch
groups for themselves.

Assuming that all the threads in a thread groups should also be in the
same process group, I think the correct action is for sys_setpgid to
also switch the thread's process group.

Since it seems that the non-leader threads in the thread group are not
attached to the process group, all that needs to be done is for their
pgrp fields to be updated. Patch against 2.6.0-test2-mm2 attached.

(Why does this matter? I'm trying to do terminal I/O in threads in a
job control environment. No, thanks, I'm perfectly sane.)

J

kernel/sys.c | 11 +++++++++++
1 files changed, 11 insertions(+)

diff -puN kernel/sys.c~thread-pgrp kernel/sys.c
--- local-2.6/kernel/sys.c~thread-pgrp 2003-08-02 00:33:06.340860431 -0700
+++ local-2.6-jeremy/kernel/sys.c 2003-08-02 00:38:13.929221706 -0700
@@ -987,6 +987,18 @@ ok_pgid:
p->pgrp = pgid;
attach_pid(p, PIDTYPE_PGID, pgid);
}
+
+ {
+ /* update all threads in thread group
+ to new process group */
+ struct task_struct *p;
+ struct pid *pidp;
+ struct list_head *l;
+
+ for_each_task_pid(pid, PIDTYPE_TGID, p, l, pidp)
+ p->pgrp = pgid;
+ }
+
err = 0;
out:
/* All paths lead to here, thus we are safe. -DaveM */
_


-
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 13:47    [W:0.100 / U:1.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site