OpenVZ Forum


Home » Mailing lists » Devel » [PATCH 2/2] Explicitly set pgid and sid of init
[PATCH 2/2] Explicitly set pgid and sid of init [message #17505] Thu, 22 February 2007 23:24 Go to next message
Sukadev Bhattiprolu is currently offline  Sukadev Bhattiprolu
Messages: 413
Registered: August 2006
Senior Member
From: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Subject: [PATCH 2/2] Explicitly set pgid and sid of init

Explicitly set pgid and sid of init process to 1.

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: Eric Biederman <ebiederm@xmission.com>
Cc: containers@lists.osdl.org
---
 init/main.c   |    1 +
 kernel/exit.c |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

Index: lx26-20-mm2/init/main.c
===================================================================
--- lx26-20-mm2.orig/init/main.c	2007-02-21 14:31:26.000000000 -0800
+++ lx26-20-mm2/init/main.c	2007-02-21 15:34:06.000000000 -0800
@@ -791,6 +791,7 @@ static int __init init(void * unused)
 	 */
 	init_pid_ns.child_reaper = current;
 
+	__set_special_pids(1, 1);
 	cad_pid = task_pid(current);
 
 	smp_prepare_cpus(max_cpus);
Index: lx26-20-mm2/kernel/exit.c
===================================================================
--- lx26-20-mm2.orig/kernel/exit.c	2007-02-21 15:33:57.000000000 -0800
+++ lx26-20-mm2/kernel/exit.c	2007-02-21 15:34:06.000000000 -0800
@@ -296,12 +296,12 @@ void __set_special_pids(pid_t session, p
 {
 	struct task_struct *curr = current->group_leader;
 
-	if (process_session(curr) != session) {
+	if (pid_nr(task_session(curr)) != session) {
 		detach_pid(curr, PIDTYPE_SID);
 		set_signal_session(curr->signal, session);
 		attach_pid(curr, PIDTYPE_SID, find_pid(session));
 	}
-	if (process_group(curr) != pgrp) {
+	if (pid_nr(task_pgrp(curr)) != pgrp) {
 		detach_pid(curr, PIDTYPE_PGID);
 		curr->signal->pgrp = pgrp;
 		attach_pid(curr, PIDTYPE_PGID, find_pid(pgrp));
_______________________________________________
Containers mailing list
Containers@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/containers
Re: [PATCH 2/2] Explicitly set pgid and sid of init [message #17520 is a reply to message #17505] Thu, 22 February 2007 23:38 Go to previous messageGo to next message
Dave Hansen is currently offline  Dave Hansen
Messages: 240
Registered: October 2005
Senior Member
On Thu, 2007-02-22 at 15:24 -0800, sukadev@us.ibm.com wrote:
> -       if (process_group(curr) != pgrp) {
> +       if (pid_nr(task_pgrp(curr)) != pgrp) { 

I wonder if there are enough of these cases to start doing:

	#define task_pgrp_nr(tsk)  pid_nr(task_pgrp(tsk))
	#define task_tgid_nr(tsk)  pid_nr(task_tgid(tsk))

etc...

-- Dave

_______________________________________________
Containers mailing list
Containers@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/containers
Re: [PATCH 2/2] Explicitly set pgid and sid of init [message #17521 is a reply to message #17520] Fri, 23 February 2007 06:17 Go to previous message
ebiederm is currently offline  ebiederm
Messages: 1354
Registered: February 2006
Senior Member
Dave Hansen <hansendc@us.ibm.com> writes:

> On Thu, 2007-02-22 at 15:24 -0800, sukadev@us.ibm.com wrote:
>> -       if (process_group(curr) != pgrp) {
>> +       if (pid_nr(task_pgrp(curr)) != pgrp) { 
>
> I wonder if there are enough of these cases to start doing:
>
> 	#define task_pgrp_nr(tsk)  pid_nr(task_pgrp(tsk))
> 	#define task_tgid_nr(tsk)  pid_nr(task_tgid(tsk))

There shouldn't be.  We should really fix the arguments of __set_special_pids
to be struct_pid *.  At which point this ugliness goes away.

Eric
_______________________________________________
Containers mailing list
Containers@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/containers
Previous Topic: Using libvzctl-0.0.2.so on C++ code
Next Topic: [PATCH] Use task_pgrp() and task_session in binfmt
Goto Forum:
  


Current Time: Wed Jul 30 06:39:11 GMT 2025

Total time taken to generate the page: 0.04217 seconds