mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Linux Kernel List <linux-kernel@vger.kernel.org>
Cc: Roland McGrath <roland@redhat.com>, Andrew Morton <akpm@osdl.org>
Subject: [PATCH] bug in setpgid()? process groups and thread groups
Date: 02 Aug 2003 00:57:28 -0700	[thread overview]
Message-ID: <1059811048.18516.43.camel@ixodes.goop.org> (raw)

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

_



             reply	other threads:[~2003-08-02  7:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-02  7:57 Jeremy Fitzhardinge [this message]
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

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=1059811048.18516.43.camel@ixodes.goop.org \
    --to=jeremy@goop.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --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®