diff -Nru linux-2.6.3/include/asm-alpha/resource.h linux/include/asm-alpha/resource.h
--- linux-2.6.3/include/asm-alpha/resource.h	2004-02-18 00:57:14.000000000 -0500
+++ linux/include/asm-alpha/resource.h	2004-03-07 21:36:41.000000000 -0500
@@ -16,8 +16,9 @@
 #define RLIMIT_NPROC	8		/* max number of processes */
 #define RLIMIT_MEMLOCK	9		/* max locked-in-memory address space */
 #define RLIMIT_LOCKS   10              /* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
 
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 /*
  * SuS says limits have to be unsigned.  Fine, it's unsigned, but
@@ -41,6 +42,7 @@
     {LONG_MAX, LONG_MAX},			/* RLIMIT_NPROC */	\
     {LONG_MAX, LONG_MAX},			/* RLIMIT_MEMLOCK */	\
     {LONG_MAX, LONG_MAX},                       /* RLIMIT_LOCKS */      \
+    {LONG_MAX, LONG_MAX},			/* RLIMIT_DEPTH */	\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-arm/resource.h linux/include/asm-arm/resource.h
--- linux-2.6.3/include/asm-arm/resource.h	2004-02-18 00:59:18.000000000 -0500
+++ linux/include/asm-arm/resource.h	2004-03-07 21:37:36.000000000 -0500
@@ -16,8 +16,9 @@
 #define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
 #define RLIMIT_AS	9		/* address space limit */
 #define RLIMIT_LOCKS	10		/* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
 
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 #ifdef __KERNEL__
 
@@ -40,6 +41,7 @@
 	{ RLIM_INFINITY, RLIM_INFINITY },	\
 	{ RLIM_INFINITY, RLIM_INFINITY },	\
 	{ RLIM_INFINITY, RLIM_INFINITY },	\
+	{ RLIM_INFINITY, RLIM_INFINITY },	\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-arm26/resource.h linux/include/asm-arm26/resource.h
--- linux-2.6.3/include/asm-arm26/resource.h	2004-02-18 00:57:12.000000000 -0500
+++ linux/include/asm-arm26/resource.h	2004-03-07 21:38:39.000000000 -0500
@@ -16,8 +16,9 @@
 #define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
 #define RLIMIT_AS	9		/* address space limit */
 #define RLIMIT_LOCKS	10		/* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
 
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 #ifdef __KERNEL__
 
@@ -40,6 +41,7 @@
 	{ RLIM_INFINITY, RLIM_INFINITY },	\
 	{ RLIM_INFINITY, RLIM_INFINITY },	\
 	{ RLIM_INFINITY, RLIM_INFINITY },	\
+	{ RLIM_INFINITY, RLIM_INFINITY },	\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-cris/resource.h linux/include/asm-cris/resource.h
--- linux-2.6.3/include/asm-cris/resource.h	2004-02-18 00:58:36.000000000 -0500
+++ linux/include/asm-cris/resource.h	2004-03-07 21:39:42.000000000 -0500
@@ -16,8 +16,9 @@
 #define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
 #define RLIMIT_AS	9		/* address space limit */
 #define RLIMIT_LOCKS   10              /* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
 
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 /*
  * SuS says limits have to be unsigned.
@@ -40,6 +41,7 @@
 	{ RLIM_INFINITY, RLIM_INFINITY },               \
         { RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
+	{ RLIM_INFINITY, RLIM_INFINITY },		\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-h8300/resource.h linux/include/asm-h8300/resource.h
--- linux-2.6.3/include/asm-h8300/resource.h	2004-02-18 00:57:14.000000000 -0500
+++ linux/include/asm-h8300/resource.h	2004-03-07 21:40:52.000000000 -0500
@@ -16,8 +16,9 @@
 #define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
 #define RLIMIT_AS	9		/* address space limit */
 #define RLIMIT_LOCKS	10		/* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
 
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 /*
  * SuS says limits have to be unsigned.
@@ -40,6 +41,7 @@
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
         { RLIM_INFINITY, RLIM_INFINITY },		\
+	{ RLIM_INFINITY, RLIM_INFINITY },		\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-i386/resource.h linux/include/asm-i386/resource.h
--- linux-2.6.3/include/asm-i386/resource.h	2004-02-18 00:57:16.000000000 -0500
+++ linux/include/asm-i386/resource.h	2004-03-07 21:34:11.000000000 -0500
@@ -16,8 +16,9 @@
 #define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
 #define RLIMIT_AS	9		/* address space limit */
 #define RLIMIT_LOCKS	10		/* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
 
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 /*
  * SuS says limits have to be unsigned.
@@ -40,6 +41,7 @@
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
         { RLIM_INFINITY, RLIM_INFINITY },		\
+	{ RLIM_INFINITY, RLIM_INFINITY },		\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-ia64/resource.h linux/include/asm-ia64/resource.h
--- linux-2.6.3/include/asm-ia64/resource.h	2004-02-18 00:58:54.000000000 -0500
+++ linux/include/asm-ia64/resource.h	2004-03-07 21:42:31.000000000 -0500
@@ -23,8 +23,9 @@
 #define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
 #define RLIMIT_AS	9		/* address space limit */
 #define RLIMIT_LOCKS	10		/* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
 
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 /*
  * SuS says limits have to be unsigned.
@@ -47,6 +48,7 @@
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
+	{ RLIM_INFINITY, RLIM_INFINITY },		\
 }
 
 # endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-m68k/resource.h linux/include/asm-m68k/resource.h
--- linux-2.6.3/include/asm-m68k/resource.h	2004-02-18 00:57:12.000000000 -0500
+++ linux/include/asm-m68k/resource.h	2004-03-07 21:43:10.000000000 -0500
@@ -16,8 +16,9 @@
 #define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
 #define RLIMIT_AS	9		/* address space limit */
 #define RLIMIT_LOCKS	10		/* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
 
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 /*
  * SuS says limits have to be unsigned.
@@ -40,6 +41,7 @@
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
         { RLIM_INFINITY, RLIM_INFINITY },		\
+	{ RLIM_INFINITY, RLIM_INFINITY },		\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-mips/resource.h linux/include/asm-mips/resource.h
--- linux-2.6.3/include/asm-mips/resource.h	2004-02-18 00:59:18.000000000 -0500
+++ linux/include/asm-mips/resource.h	2004-03-07 21:44:18.000000000 -0500
@@ -23,8 +23,9 @@
 #define RLIMIT_NPROC 8			/* max number of processes */
 #define RLIMIT_MEMLOCK 9		/* max locked-in-memory address space */
 #define RLIMIT_LOCKS 10			/* maximum file locks held */
+#define RLIMIT_DEPTH 11			/* max process depth */
 
-#define RLIM_NLIMITS 11			/* Number of limit flavors.  */
+#define RLIM_NLIMITS 12			/* Number of limit flavors.  */
 
 #ifdef __KERNEL__
 
@@ -54,6 +55,7 @@
 	{ 0,             0             },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
+	{ RLIM_INFINITY, RLIM_INFINITY },		\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-parisc/resource.h linux/include/asm-parisc/resource.h
--- linux-2.6.3/include/asm-parisc/resource.h	2004-02-18 00:58:44.000000000 -0500
+++ linux/include/asm-parisc/resource.h	2004-03-07 21:44:55.000000000 -0500
@@ -16,8 +16,9 @@
 #define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
 #define RLIMIT_AS	9		/* address space limit */
 #define RLIMIT_LOCKS	10		/* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
 
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 /*
  * SuS says limits have to be unsigned.
@@ -40,6 +41,7 @@
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
+	{ RLIM_INFINITY, RLIM_INFINITY },		\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-ppc/resource.h linux/include/asm-ppc/resource.h
--- linux-2.6.3/include/asm-ppc/resource.h	2004-02-18 00:57:30.000000000 -0500
+++ linux/include/asm-ppc/resource.h	2004-03-07 21:45:38.000000000 -0500
@@ -12,8 +12,9 @@
 #define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
 #define RLIMIT_AS	9		/* address space limit(?) */
 #define RLIMIT_LOCKS	10		/* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
 
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 #ifdef __KERNEL__
 
@@ -37,6 +38,7 @@
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
+	{ RLIM_INFINITY, RLIM_INFINITY },		\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-ppc64/resource.h linux/include/asm-ppc64/resource.h
--- linux-2.6.3/include/asm-ppc64/resource.h	2004-02-18 00:58:44.000000000 -0500
+++ linux/include/asm-ppc64/resource.h	2004-03-07 21:46:07.000000000 -0500
@@ -21,8 +21,9 @@
 #define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
 #define RLIMIT_AS	9		/* address space limit(?) */
 #define RLIMIT_LOCKS	10		/* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
 
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 #ifdef __KERNEL__
 
@@ -46,6 +47,7 @@
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
+	{ RLIM_INFINITY, RLIM_INFINITY },		\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-s390/resource.h linux/include/asm-s390/resource.h
--- linux-2.6.3/include/asm-s390/resource.h	2004-02-18 00:57:22.000000000 -0500
+++ linux/include/asm-s390/resource.h	2004-03-07 21:46:47.000000000 -0500
@@ -24,8 +24,9 @@
 #define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
 #define RLIMIT_AS	9		/* address space limit */
 #define RLIMIT_LOCKS	10		/* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
   
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 /*
  * SuS says limits have to be unsigned.
@@ -48,6 +49,7 @@
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
+	{ RLIM_INFINITY, RLIM_INFINITY },		\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-sh/resource.h linux/include/asm-sh/resource.h
--- linux-2.6.3/include/asm-sh/resource.h	2004-02-18 00:58:34.000000000 -0500
+++ linux/include/asm-sh/resource.h	2004-03-07 21:47:16.000000000 -0500
@@ -16,8 +16,9 @@
 #define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
 #define RLIMIT_AS	9		/* address space limit */
 #define RLIMIT_LOCKS	10		/* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
 
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 #ifdef __KERNEL__
 
@@ -40,6 +41,7 @@
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
+	{ RLIM_INFINITY, RLIM_INFINITY },		\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-sparc/resource.h linux/include/asm-sparc/resource.h
--- linux-2.6.3/include/asm-sparc/resource.h	2004-02-18 00:57:16.000000000 -0500
+++ linux/include/asm-sparc/resource.h	2004-03-07 21:47:51.000000000 -0500
@@ -22,8 +22,9 @@
 #define RLIMIT_MEMLOCK  8               /* max locked-in-memory address space */
 #define RLIMIT_AS       9               /* address space limit */
 #define RLIMIT_LOCKS	10		/* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
 
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 /*
  * SuS says limits have to be unsigned.
@@ -45,6 +46,7 @@
     {RLIM_INFINITY, RLIM_INFINITY},	\
     {RLIM_INFINITY, RLIM_INFINITY},	\
     {RLIM_INFINITY, RLIM_INFINITY}	\
+    {RLIM_INFINITY, RLIM_INFINITY}	\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-sparc64/resource.h linux/include/asm-sparc64/resource.h
--- linux-2.6.3/include/asm-sparc64/resource.h	2004-02-18 00:57:12.000000000 -0500
+++ linux/include/asm-sparc64/resource.h	2004-03-07 21:48:47.000000000 -0500
@@ -22,8 +22,9 @@
 #define RLIMIT_MEMLOCK  8               /* max locked-in-memory address space */
 #define RLIMIT_AS       9               /* address space limit */
 #define RLIMIT_LOCKS	10		/* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
 
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 /*
  * SuS says limits have to be unsigned.
@@ -44,6 +45,7 @@
     {RLIM_INFINITY, RLIM_INFINITY},	\
     {RLIM_INFINITY, RLIM_INFINITY},	\
     {RLIM_INFINITY, RLIM_INFINITY}	\
+    {RLIM_INFINITY, RLIM_INFINITY}	\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-v850/resource.h linux/include/asm-v850/resource.h
--- linux-2.6.3/include/asm-v850/resource.h	2004-02-18 00:57:14.000000000 -0500
+++ linux/include/asm-v850/resource.h	2004-03-07 21:49:40.000000000 -0500
@@ -16,8 +16,9 @@
 #define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
 #define RLIMIT_AS	9		/* address space limit */
 #define RLIMIT_LOCKS	10		/* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
 
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 /*
  * SuS says limits have to be unsigned.
@@ -40,6 +41,7 @@
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
         { RLIM_INFINITY, RLIM_INFINITY },		\
+	{ RLIM_INFINITY, RLIM_INFINITY },		\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/include/asm-x86_64/resource.h linux/include/asm-x86_64/resource.h
--- linux-2.6.3/include/asm-x86_64/resource.h	2004-02-18 00:58:48.000000000 -0500
+++ linux/include/asm-x86_64/resource.h	2004-03-07 21:50:26.000000000 -0500
@@ -16,8 +16,9 @@
 #define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
 #define RLIMIT_AS	9		/* address space limit */
 #define RLIMIT_LOCKS	10		/* maximum file locks held */
+#define RLIMIT_DEPTH	11		/* max process depth */
 
-#define RLIM_NLIMITS	11
+#define RLIM_NLIMITS	12
 
 /*
  * SuS says limits have to be unsigned.
@@ -40,6 +41,7 @@
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
 	{ RLIM_INFINITY, RLIM_INFINITY },		\
         { RLIM_INFINITY, RLIM_INFINITY },		\
+	{ RLIM_INFINITY, RLIM_INFINITY },		\
 }
 
 #endif /* __KERNEL__ */
diff -Nru linux-2.6.3/kernel/fork.c linux/kernel/fork.c
--- linux-2.6.3/kernel/fork.c	2004-02-18 00:57:14.000000000 -0500
+++ linux/kernel/fork.c	2004-03-07 13:56:44.000000000 -0500
@@ -1008,6 +1008,20 @@
 		p->real_parent = current;
 	p->parent = p->real_parent;
 
+
+	/*
+	 *  Check if the RLIMIT_DEPTH was set and then if parent 
+	 *  have a spare depth. Finally update child's depth limits. 
+	 */
+	if (p->parent->rlim[RLIMIT_DEPTH].rlim_cur != RLIM_INFINITY) {
+		if (!p->parent->rlim[RLIMIT_DEPTH].rlim_cur) {
+			retval = -EPERM;
+			goto bad_fork_cleanup_namespace;
+		}
+		p->rlim[RLIMIT_DEPTH].rlim_cur = p->parent->rlim[RLIMIT_DEPTH].rlim_cur - 1;
+		p->rlim[RLIMIT_DEPTH].rlim_max = p->parent->rlim[RLIMIT_DEPTH].rlim_max - 1;
+	}
+
 	if (clone_flags & CLONE_THREAD) {
 		spin_lock(&current->sighand->siglock);
 		/*
