linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bug in setpgid()? process groups and thread groups
@ 2003-08-02  7:57 Jeremy Fitzhardinge
  2003-08-02  8:20 ` Ulrich Drepper
  0 siblings, 1 reply; 10+ messages in thread
From: Jeremy Fitzhardinge @ 2003-08-02  7:57 UTC (permalink / raw)
  To: Linux Kernel List; +Cc: Roland McGrath, Andrew Morton

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 */

_



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2003-08-03 21:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-02  7:57 [PATCH] bug in setpgid()? process groups and thread groups Jeremy Fitzhardinge
2003-08-02  8:20 ` Ulrich Drepper
2003-08-02  8:50   ` Jeremy Fitzhardinge
2003-08-02 19:08     ` Roland McGrath
2003-08-02 20:30       ` Nicholas Miell
2003-08-02 20:51       ` Alan Cox
2003-08-03  7:22         ` Florian Weimer
2003-08-03 21:00           ` Alan Cox
2003-08-03  4:15       ` Jeremy Fitzhardinge
2003-08-02 18:39   ` William Lee Irwin III

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).