[RFC][PATCH] Use task_pgrp()/task_session() in copy_process

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am trying to replace process_group() and process_session() calls in
copy_process() with task_pgrp() and task_session().

Since task_pid() task_pgrp(), task_session() for the swapper are NULL, I
had to treat swapper as special in this patch and would like some comments.

Should we instead do some magic in start_kernel() so we don't have to treat
swapper special or maybe move the check for pid_t == 0 into task_pgrp()/
task_session() ?

P.S: For find_attach_pid()/attach_pid(), pls see my recent patches to Containers@
     and LKML.
---
From: Sukadev Bhattiprolu <sukadev at us.ibm.com>

Replace process_group() and process_session() with container-friendly task_pgrp() and
task_session().

Signed-off-by: Sukadev Bhattiprolu <sukadev at us.ibm.com>
Cc: Cedric Le Goater <clg at fr.ibm.com>
Cc: Dave Hansen <haveblue at us.ibm.com>
Cc: Serge Hallyn <serue at us.ibm.com>
Cc: containers at lists.osdl.org
---
 kernel/fork.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

Index: lx26-20-rc2-mm1/kernel/fork.c
===================================================================
--- lx26-20-rc2-mm1.orig/kernel/fork.c	2007-01-11 07:18:03.383853328 -0800
+++ lx26-20-rc2-mm1/kernel/fork.c	2007-01-11 07:19:55.550801360 -0800
@@ -1248,8 +1248,13 @@ static struct task_struct *copy_process(
 			p->signal->tty = current->signal->tty;
 			p->signal->pgrp = process_group(current);
 			set_signal_session(p->signal, process_session(current));
-			find_attach_pid(p, PIDTYPE_PGID, process_group(p));
-			find_attach_pid(p, PIDTYPE_SID, process_session(p));
+			if (current->pid) {
+				attach_pid(p, PIDTYPE_PGID, task_pgrp(current));
+				attach_pid(p, PIDTYPE_SID, task_session(current));
+			} else {
+				find_attach_pid(p, PIDTYPE_PGID, process_group(current));
+				find_attach_pid(p, PIDTYPE_SID, process_session(current));
+			}
 
 			list_add_tail_rcu(&p->tasks, &init_task.tasks);
 			__get_cpu_var(process_counts)++;



[Index of Archives]     [Cgroups]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux