OpenVZ Forum


Home » Mailing lists » Devel » [RFC][PATCH] Use task_pgrp()/task_session() in copy_process
[RFC][PATCH] Use task_pgrp()/task_session() in copy_process [message #17128] Thu, 11 January 2007 15:58 Go to previous message
Sukadev Bhattiprolu is currently offline  Sukadev Bhattiprolu
Messages: 413
Registered: August 2006
Senior Member
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@us.ibm.com>

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

Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Cc: Cedric Le Goater <clg@fr.ibm.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Cc: Serge Hallyn <serue@us.ibm.com>
Cc: containers@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)++;

_______________________________________________
Containers mailing list
Containers@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/containers
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: + rename-attach_pid-to-find_attach_pid.patch added to -mm tree
Next Topic: + attach_pid-with-struct-pid-parameter.patch added to -mm tree
Goto Forum:
  


Current Time: Tue Jul 22 05:01:20 GMT 2025

Total time taken to generate the page: 0.17705 seconds